1
0
Fork 0

Add support for TTY mode on Linux/OSX in script handlers when running in interactive mode, fixes #5856, fixes #3299, closes #4036

pull/8566/head
Jordi Boggiano 2020-01-31 15:45:33 +01:00
parent 58e2956b95
commit f572636628
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 6 additions and 3 deletions

View File

@ -174,7 +174,7 @@ class EventDispatcher
$flags = $event->getFlags();
if (substr($callable, 0, 10) === '@composer ') {
$exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
if (0 !== ($exitCode = $this->process->execute($exec))) {
if (0 !== ($exitCode = $this->process->execute($exec, $ignoredOutput, null, $this->io->isInteractive()))) {
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
@ -248,7 +248,7 @@ class EventDispatcher
}
}
if (0 !== ($exitCode = $this->process->execute($exec))) {
if (0 !== ($exitCode = $this->process->execute($exec, $ignoredOutput, null, $this->io->isInteractive()))) {
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);

View File

@ -41,7 +41,7 @@ class ProcessExecutor
* @param string $cwd the working directory
* @return int statuscode
*/
public function execute($command, &$output = null, $cwd = null)
public function execute($command, &$output = null, $cwd = null, $tty = false)
{
if ($this->io && $this->io->isDebug()) {
$safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
@ -70,6 +70,9 @@ class ProcessExecutor
} else {
$process = new Process($command, $cwd, null, null, static::getTimeout());
}
if (!Platform::isWindows() && $tty) {
$process->setTty(true);
}
$callback = is_callable($output) ? $output : array($this, 'outputHandler');
$process->run($callback);