diff --git a/src/Common/ExecCommand.php b/src/Common/ExecCommand.php index a5c92aa5..c1aee0f5 100644 --- a/src/Common/ExecCommand.php +++ b/src/Common/ExecCommand.php @@ -146,7 +146,8 @@ protected function executeCommand($command) $this, $result_data->getExitCode(), $result_data->getMessage(), - $result_data->getData() + $result_data->getData(), + $result_data->getErrorOutput() ); } } diff --git a/src/Common/ExecTrait.php b/src/Common/ExecTrait.php index 9959d304..6ea0e723 100644 --- a/src/Common/ExecTrait.php +++ b/src/Common/ExecTrait.php @@ -398,7 +398,8 @@ protected function execute($process, $output_callback = null) return new ResultData( $this->process->getExitCode(), $this->process->getOutput(), - $this->getResultData() + $this->getResultData(), + $this->process->getErrorOutput(), ); } @@ -408,7 +409,8 @@ protected function execute($process, $output_callback = null) return new ResultData( $this->process->getExitCode(), $e->getMessage(), - $this->getResultData() + $this->getResultData(), + $this->process->getErrorOutput(), ); } return new ResultData($this->process->getExitCode()); diff --git a/src/Result.php b/src/Result.php index 6c9ea781..43836351 100644 --- a/src/Result.php +++ b/src/Result.php @@ -31,10 +31,11 @@ class Result extends ResultData implements OutputAwareInterface, InflectionInter * @param int $exitCode * @param string $message * @param array $data + * @param string $errorOutput */ - public function __construct(TaskInterface $task, $exitCode, $message = '', $data = []) + public function __construct(TaskInterface $task, $exitCode, $message = '', $data = [], $errorOutput = '') { - parent::__construct($exitCode, $message, $data); + parent::__construct($exitCode, $message, $data, $errorOutput); $this->task = $task; $this->inflect($task); $this->printResult(); @@ -292,6 +293,6 @@ public function injectDependencies($child) */ private function exitEarly($status) { - throw new TaskExitException($this->getTask(), $this->getMessage(), $status); + throw new TaskExitException($this->getTask(), $this->getErrorOutput(), $status); } } diff --git a/src/ResultData.php b/src/ResultData.php index bf064d65..05215a02 100644 --- a/src/ResultData.php +++ b/src/ResultData.php @@ -13,6 +13,11 @@ class ResultData extends Data implements ExitCodeInterface, OutputDataInterface */ protected $exitCode; + /** + * @var string + */ + protected $errorOutput; + const EXITCODE_OK = 0; const EXITCODE_ERROR = 1; /** Symfony Console handles these conditions; Robo returns the status @@ -30,10 +35,12 @@ class ResultData extends Data implements ExitCodeInterface, OutputDataInterface * @param int $exitCode * @param string $message * @param array $data + * @param string $errorOutput */ - public function __construct($exitCode = self::EXITCODE_OK, $message = '', $data = []) + public function __construct($exitCode = self::EXITCODE_OK, $message = '', $data = [], $errorOutput = '') { $this->exitCode = $exitCode; + $this->errorOutput = $errorOutput; parent::__construct($message, $data); } @@ -108,4 +115,12 @@ public function wasCancelled() { return $this->exitCode == self::EXITCODE_USER_CANCEL; } + + /** + * @return string + */ + public function getErrorOutput() + { + return $this->errorOutput; + } }