From 4cb8c7fb9619cb7a75010fe956a8288d2474c059 Mon Sep 17 00:00:00 2001 From: Yann Schepens Date: Thu, 21 May 2015 09:33:20 +0200 Subject: [PATCH] Display command output in realtime with debug mode, do not display debug output with this mode --- src/functions.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/functions.php b/src/functions.php index 2b831587..7824f226 100644 --- a/src/functions.php +++ b/src/functions.php @@ -314,21 +314,21 @@ function runLocally($command, $timeout = 60) $process = new Symfony\Component\Process\Process($command); $process->setTimeout($timeout); - $process->run(); + $process->run(function($type, $buffer){ + if (isDebug()) { + if ('err' === $type) { + write("> $buffer"); + } else { + write("> $buffer"); + } + } + }); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } - - $output = $process->getOutput(); - - if (isDebug() && !empty($output)) { - writeln(array_map(function ($line) { - return "> $line"; - }, explode("\n", $output))); - } - - return new Result($output); + + return new Result($process->getOutput()); } /**