示例#1
0
文件: Task.php 项目: netresearch/kite
 /**
  * The preview for this task - this is called right before execution and
  * in preview mode
  *
  * @return void
  */
 public function preview()
 {
     $message = $this->get('message');
     if ($message) {
         $this->console->output($message);
     }
 }
示例#2
0
 /**
  * Execute a shell command
  *
  * @param callable|null $callback A PHP callback to run whenever there is some
  *                                output available on STDOUT or STDERR
  *
  * @return mixed The output of the shell command or FALSE if the command returned a non-zero exit code and $ignoreErrors was enabled.
  */
 public function run($callback = null)
 {
     $command = $this->getCommandLine();
     $this->console->output('<cmd>' . $this->getWorkingDirectory() . ' > ' . $command . '</cmd>', OutputInterface::VERBOSITY_VERBOSE);
     if ($this->dryRun) {
         return null;
     }
     parent::run(function ($type, $buffer) use($callback) {
         if ($callback) {
             call_user_func($callback, $type, $buffer);
         }
         if (!$this->shy || $type !== self::OUT) {
             $this->console->output($buffer, $this->pt ? $this->console->getVerbosity() : OutputInterface::VERBOSITY_DEBUG, false, !$this->pt);
         }
     });
     if ($this->getExitCode() !== 0) {
         throw new ProcessFailedException($this);
     }
     return trim($this->getOutput());
 }