/** * 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); } }
/** * 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()); }