From 58875d5c8ad30db5b1321b36c734bdf9723a714f Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 4 Mar 2017 12:55:13 +0700 Subject: [PATCH] Fixed shell plugin execution. Issue #30 --- src/PHPCensor/Helper/BaseCommandExecutor.php | 9 +++++--- src/PHPCensor/Plugin/Shell.php | 22 +++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/PHPCensor/Helper/BaseCommandExecutor.php b/src/PHPCensor/Helper/BaseCommandExecutor.php index d43736ec..dda4ab6d 100644 --- a/src/PHPCensor/Helper/BaseCommandExecutor.php +++ b/src/PHPCensor/Helper/BaseCommandExecutor.php @@ -77,10 +77,12 @@ abstract class BaseCommandExecutor implements CommandExecutorInterface { $this->lastOutput = []; - $command = call_user_func_array('sprintf', $args); - $this->logger->logDebug('Command: ' . $command); $this->logger->logDebug('Args: ' . json_encode($args)); + $command = call_user_func_array('sprintf', $args); + + $this->logger->logDebug('Command: ' . $command); + if ($this->quiet) { $this->logger->log('Executing: ' . $command); } @@ -119,11 +121,12 @@ abstract class BaseCommandExecutor implements CommandExecutorInterface } $rtn = false; - if ($status == 0) { $rtn = true; } + $this->logger->logDebug('Execution status: ' . $status); + return $rtn; } diff --git a/src/PHPCensor/Plugin/Shell.php b/src/PHPCensor/Plugin/Shell.php index 45976f98..2ab11a99 100644 --- a/src/PHPCensor/Plugin/Shell.php +++ b/src/PHPCensor/Plugin/Shell.php @@ -1,11 +1,4 @@ - * @package PHPCI - * @subpackage Plugins + * @author Kinn Coelho Julião */ class Shell extends Plugin { + /** + * @var array + */ protected $args; /** @@ -65,19 +59,19 @@ class Shell extends Plugin /** * Runs the shell command. + * + * @return bool */ public function execute() { - $success = true; - foreach ($this->commands as $command) { $command = $this->builder->interpolate($command); if (!$this->builder->executeCommand($command)) { - $success = false; + return false; } } - return $success; + return true; } }