From 299ec5ce7d092e004ad1a9417dc27b8da7a202f4 Mon Sep 17 00:00:00 2001 From: aliaxander Date: Mon, 22 Feb 2016 01:03:25 +0300 Subject: [PATCH] test shell2 --- PHPCI/Plugin/Shell2.php | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 PHPCI/Plugin/Shell2.php diff --git a/PHPCI/Plugin/Shell2.php b/PHPCI/Plugin/Shell2.php new file mode 100644 index 00000000..3e3bfc2e --- /dev/null +++ b/PHPCI/Plugin/Shell2.php @@ -0,0 +1,85 @@ + + * @package PHPCI + * @subpackage Plugins + */ +class Shell2 implements \PHPCI\Plugin +{ + /** + * @var \PHPCI\Builder + */ + protected $phpci; + + /** + * @var \PHPCI\Model\Build + */ + protected $build; + + protected $args; + + /** + * @var string[] $commands The commands to be executed + */ + protected $commands = array(); + + /** + * Standard Constructor + * + * $options['directory'] Output Directory. Default: %BUILDPATH% + * $options['filename'] Phar Filename. Default: build.phar + * $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/ + * $options['stub'] Stub Content. No Default Value + * + * @param Builder $phpci + * @param Build $build + * @param array $options + */ + public function __construct(Builder $phpci, Build $build, array $options = array()) + { + $this->phpci = $phpci; + $this->build = $build; + + if (isset($options['command'])) { + // Keeping this for backwards compatibility, new projects should use interpolation vars. + $options['command'] = str_replace("%buildpath%", $options['directory'], $options['command']); + $this->commands = $options['command']; + + return; + } + } + + /** + * Runs the shell command. + */ + public function execute() + { + if (!defined('ENABLE_SHELL_PLUGIN') || !ENABLE_SHELL_PLUGIN) { + throw new \Exception(Lang::get('shell_not_enabled')); + } + + $success = true; + + if (!$this->phpci->executeCommand($this->commands)) { + $success = false; + } + + return $success; + } +}