Skip to content

Commit b45d189

Browse files
committed
Enhance TTY support handling
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent b905be2 commit b45d189

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/Command/AbstractCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,23 @@ protected function runProcess(Process $command, OutputInterface $output): int
5656
$processHelper = $this->getHelper('process');
5757

5858
$command = $command->setWorkingDirectory($this->getCurrentWorkingDirectory());
59+
$callback = null;
5960

6061
if (Process::isTtySupported()) {
6162
$command->setTty(true);
6263
} else {
6364
$output->writeln('<comment>Warning: TTY is not supported. The command may not display output as expected.</comment>');
65+
66+
$callback = function (string $type, string $buffer) use ($output) {
67+
$output->write($buffer);
68+
};
6469
}
6570

66-
$process = $processHelper->run($output, $command);
71+
$process = $processHelper->run(
72+
output: $output,
73+
cmd: $command,
74+
callback: $callback
75+
);
6776

6877
if (! $process->isSuccessful()) {
6978
$output->writeln(\sprintf(

tests/Command/AbstractCommandTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function setUp(): void
100100
->willReturn(true);
101101

102102
$this->processHelper
103-
->run(Argument::type(OutputInterface::class), Argument::type(Process::class))
103+
->run(Argument::type(OutputInterface::class), Argument::type(Process::class), Argument::cetera())
104104
->willReturn($process->reveal());
105105

106106
$this->command->setApplication($this->application->reveal());
@@ -176,7 +176,7 @@ protected function willRunProcessWithCallback(callable $callback, bool $isSucces
176176
->shouldBeCalled();
177177

178178
$this->processHelper
179-
->run(Argument::type(OutputInterface::class), Argument::that($callback))
179+
->run(Argument::type(OutputInterface::class), Argument::that($callback), Argument::cetera())
180180
->willReturn($process->reveal())
181181
->shouldBeCalled();
182182
}

0 commit comments

Comments
 (0)