runLocally works like run.

This commit is contained in:
Anton Medvedev 2015-05-13 10:29:56 +07:00
parent 56ba9f7dae
commit 3ff86dc927
2 changed files with 18 additions and 2 deletions

View File

@ -304,6 +304,12 @@ function run($command)
*/
function runLocally($command, $timeout = 60)
{
$command = env()->parse($command);
if (isVeryVerbose()) {
writeln("<comment>Run locally</comment>: $command");
}
$process = new Symfony\Component\Process\Process($command);
$process->setTimeout($timeout);
$process->run();
@ -312,7 +318,15 @@ function runLocally($command, $timeout = 60)
throw new \RuntimeException($process->getErrorOutput());
}
return new Result($process->getOutput());
$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);
}
/**

View File

@ -8,6 +8,7 @@
namespace Deployer;
use Deployer\Console\Application;
use Deployer\Server\Environment;
use Deployer\Task\Context;
class FunctionsTest extends \PHPUnit_Framework_TestCase
@ -29,9 +30,10 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$server = $this->getMockBuilder('Deployer\Server\ServerInterface')->disableOriginalConstructor()->getMock();
$env = $this->getMockBuilder('Deployer\Server\Environment')->disableOriginalConstructor()->getMock();
$env = new Environment();
$this->deployer = new Deployer($this->console, $input, $output);
Context::push(new Context($server, $env, $input, $output));
}
protected function tearDown()