Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Fix typo.
  Code style fixes.
  Improve output.
  • Loading branch information
Jelle-S committed Mar 9, 2017
2 parents d70d526 + a7a68c9 commit feced32
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/PackageProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ protected function getFiles()
{
$this->mirrorDir();
$this->cleanMirrorDir();
$this->printTaskInfo('Retrieving files to package.');
$mirrorFinder = new Finder();
$mirrorFinder->ignoreDotFiles(false);
$add = [];
Expand All @@ -143,26 +144,36 @@ protected function mirrorDir()
if (file_exists($this->tmpDir)) {
$this->fs->remove($this->tmpDir);
}

$this->printTaskInfo(sprintf(
'Creating temporary directory %s.',
$this->tmpDir
));
$this->fs->mkdir($this->tmpDir);
$tmpRealPath = realpath($this->tmpDir);

$directoryIterator = new \RecursiveDirectoryIterator($this->dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$recursiveIterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
$filterIterator = new \CallbackFilterIterator(
$recursiveIterator,
function ($current) use ($tmpRealPath)
{
function ($current) use ($tmpRealPath) {
return strpos($current->getRealPath(), $tmpRealPath) !== 0;
}
);
$this->printTaskInfo(sprintf(
'Mirroring directory %s to temporary directory %s.',
$this->dir,
$tmpRealPath
));
foreach ($filterIterator as $item) {
if (strpos($item->getRealPath(), $tmpRealPath) === 0) {
continue;
continue;
}
if (is_link($item)) {
if ($item->getRealPath() !== false) {
$this->fs->symlink($item->getLinkTarget(), $this->tmpDir . DIRECTORY_SEPARATOR . $filterIterator->getSubPathName());
$this->fs->symlink(
$item->getLinkTarget(),
$this->tmpDir . DIRECTORY_SEPARATOR . $filterIterator->getSubPathName()
);
}
continue;
}
Expand All @@ -182,6 +193,7 @@ function ($current) use ($tmpRealPath)
*/
protected function cleanMirrorDir()
{
$this->printTaskInfo(sprintf('Cleaning directory %s.', $this->tmpDir));
if (empty($this->ignoreFileNames)) {
return;
}
Expand Down Expand Up @@ -211,6 +223,9 @@ public function run()
$this->add($this->getFiles());
$result = parent::run();
if ($this->useTmpDir) {
$this->printTaskInfo(
sprintf('Removing temporary directory %s.', $this->tmpDir)
);
$this->fs->remove($this->tmpDir);
}
return $result;
Expand Down

0 comments on commit feced32

Please sign in to comment.