/** * Show messages only on php script die! */ public function __destruct() { foreach ($this->_info as $message) { Cli::out($message, false); } foreach ($this->_error as $message) { Cli::err($message, false); } }
/** * @param $key * @param $value */ protected function _tcEcho($key, $value) { $key = str_replace("'", "\\'", $key); $key = $this->_prefix ? $this->_prefix . ': ' . $key : $key; if (strpos($value, '.') || is_float($value)) { $value = round($value, 6); } else { $value = str_replace("'", "\\'", $value); } Cli::out("##teamcity[buildStatisticValue key='{$key}' value='{$value}']"); }
/** * Execute cli commands * * @param string $command * @param array $args * @param null $cwd * @param bool $verbose * @return string * @throws ProcessFailedException * @throws \Exception */ public static function exec($command, $args = array(), $cwd = null, $verbose = false) { if (!class_exists('\\Symfony\\Component\\Process\\Process')) { throw new \Exception("Symfony/Process package required for Cli::exec() method"); // @codeCoverageIgnore } $cmd = self::build($command, $args); $cwd = $cwd ? $cwd = realpath($cwd) : null; //@codeCoverageIgnoreStart if ($verbose) { // Only in testing mode if (function_exists('\\JBZoo\\PHPUnit\\cliMessage')) { \JBZoo\PHPUnit\cliMessage('Process: ' . $cmd); \JBZoo\PHPUnit\cliMessage('CWD: ' . $cwd); } else { Cli::out('Process: ' . $cmd); Cli::out('CWD: ' . $cwd); } } //@codeCoverageIgnoreEnd // execute command $process = new Process($cmd, $cwd); $process->run(); // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return $process->getOutput(); }
/** * @param string $message * @param bool $addEol */ public function out($message, $addEol = true) { if (function_exists('\\JBZoo\\PHPUnit\\cliMessage')) { \JBZoo\PHPUnit\cliMessage($message, $addEol); } else { Cli::out($message, $addEol); } }