Skip to content

Commit

Permalink
Merge pull request #275 from yannschepens/master
Browse files Browse the repository at this point in the history
Realtime output in runLocally function
  • Loading branch information
Anton Medvedev committed May 23, 2015
2 parents 9842ccf + 4cb8c7f commit e168c81
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<fg=red>></fg=red> $buffer");
} else {
write("<fg=green>></fg=green> $buffer");
}
}
});

if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}

$output = $process->getOutput();

if (isDebug() && !empty($output)) {
writeln(array_map(function ($line) {
return "<fg=red>></fg=red> $line";
}, explode("\n", $output)));
}

return new Result($output);

return new Result($process->getOutput());
}

/**
Expand Down

0 comments on commit e168c81

Please sign in to comment.