Skip to content

Commit

Permalink
Issue #1088 - Use TaskAccessor trait in Task\Archive\Extract (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sweetchuck authored Jan 24, 2022
1 parent ffaf2a7 commit 1daaeae
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Task/Archive/Extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Robo\Result;
use Robo\Task\BaseTask;
use Robo\Task\Filesystem\FilesystemStack;
use Robo\Task\Filesystem\DeleteDir;
use Robo\Task\Filesystem\Tasks as FilesystemTaskLoader;
use Robo\Contract\BuilderAwareInterface;
use Robo\Common\BuilderAwareTrait;
use Robo\TaskAccessor;

/**
* Extracts an archive.
Expand All @@ -34,7 +33,8 @@
*/
class Extract extends BaseTask implements BuilderAwareInterface
{
use BuilderAwareTrait;
use TaskAccessor;
use FilesystemTaskLoader;

/**
* @var string
Expand Down Expand Up @@ -131,16 +131,14 @@ public function run()
$filesInExtractLocation = glob("$extractLocation/*");
$hasEncapsulatingFolder = ((count($filesInExtractLocation) == 1) && is_dir($filesInExtractLocation[0]));
if ($hasEncapsulatingFolder && !$this->preserveTopDirectory) {
$result = (new FilesystemStack())
->inflect($this)
$this
->taskFilesystemStack()
->rename($filesInExtractLocation[0], $this->to)
->run();
(new DeleteDir($extractLocation))
->inflect($this)
->remove($extractLocation)
->run();
} else {
$result = (new FilesystemStack())
->inflect($this)
$this
->taskFilesystemStack()
->rename($extractLocation, $this->to)
->run();
}
Expand Down

0 comments on commit 1daaeae

Please sign in to comment.