/** * @todo improve output (also @see ShellTask) * * @param $target * @param Version $version * @throws \RuntimeException */ public function execute($target, Version $version) { $command = $this->getCommand($target, $version, $this->options['command']); $this->output(sprintf('Executing: <comment>%s</comment>', $command)); $hasOutput = false; $self = $this; $outputter = function ($buffer) use($self, &$hasOutput) { if (false === $self->io->isVerbose()) { return; } if (!$hasOutput) { $this->io->write(''); $this->io->write(''); $hasOutput = true; } $lines = explode("\n", $buffer); foreach ($lines as $line) { if ($output = trim($line, "\r\n")) { $self->io->write(sprintf('> %s', $output)); } } }; if ($exitCode = $this->transporter->exec($command, $outputter) != 0) { throw new \RuntimeException(sprintf('The command "%s" failed.' . "\nExit Code: %s", $command, $exitCode)); } }