Beispiel #1
0
 public function toCreateATmpDirUsingShortcut(CliGuy $I)
 {
     // Create a temporary directory, using our function name as
     // the prefix for the directory name.
     $tmpPath = $I->shortcutTmpDir(__FUNCTION__);
     $I->seeFileFound($tmpPath);
     // Creating a temporary directory without a task collection will
     // cause the temporary directory to be deleted when the program
     // terminates.  We can force it to clean up sooner by calling
     // TransientManager::complete(); note that this deletes ALL global tmp
     // directories, so this is not thread-safe!  Useful in tests, though.
     Temporary::complete();
     $I->dontSeeFileFound($tmpPath);
 }
 protected function fixTask($task, $args)
 {
     $task->inflect($this);
     if ($task instanceof BuilderAwareInterface) {
         $task->setBuilder($this);
     }
     // Do not wrap our wrappers.
     if ($task instanceof CompletionWrapper || $task instanceof Simulator) {
         return $task;
     }
     // Remember whether or not this is a task before
     // it gets wrapped in any decorator.
     $isTask = $task instanceof TaskInterface;
     $isCollection = $task instanceof NestedCollectionInterface;
     // If the task implements CompletionInterface, ensure
     // that its 'complete' method is called when the application
     // terminates -- but only if its 'run' method is called
     // first.  If the task is added to a collection, then the
     // task will be unwrapped via its `original` method, and
     // it will be re-wrapped with a new completion wrapper for
     // its new collection.
     if ($task instanceof CompletionInterface) {
         $task = new CompletionWrapper(Temporary::getCollection(), $task);
     }
     // If we are in simulated mode, then wrap any task in
     // a TaskSimulator.
     if ($isTask && !$isCollection && $this->isSimulated()) {
         $task = new \Robo\Task\Simulator($task, $args);
         $task->inflect($this);
     }
     return $task;
 }
Beispiel #3
0
 /**
  * @param $prefix
  * @param $base
  * @param $includeRandomPart
  * @return TmpDir
  */
 protected function taskTmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true)
 {
     return Temporary::wrap(new TmpDir($prefix, $base, $includeRandomPart));
 }
Beispiel #4
0
 /**
  * @param $prefix
  * @param $base
  * @param $includeRandomPart
  * @return TmpFile
  */
 protected function taskTmpFile($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true)
 {
     return Temporary::wrap(new TmpFile($filename, $extension, $baseDir, $includeRandomPart));
 }
Beispiel #5
0
 /**
  * @param $dir
  * @return string|empty
  */
 protected function _tmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true)
 {
     $result = Temporary::wrap(new TmpDir($prefix, $base, $includeRandomPart))->run();
     $data = $result->getData() + ['path' => ''];
     return $data['path'];
 }