@@ -64,42 +64,36 @@ public function __construct(?Filesystem $filesystem = null)
6464 *
6565 * @param Process $command the configured process instance to run
6666 * @param OutputInterface $output the output interface to log warnings or results
67+ * @param bool $tty
6768 *
6869 * @return int the status code of the command execution
6970 */
70- protected function runProcess (Process $ command , OutputInterface $ output ): int
71+ protected function runProcess (Process $ command , OutputInterface $ output, bool $ tty = true ): int
7172 {
7273 /** @var ProcessHelper $processHelper */
7374 $ processHelper = $ this ->getHelper ('process ' );
7475
7576 $ command = $ command ->setWorkingDirectory ($ this ->getCurrentWorkingDirectory ());
7677 $ callback = null ;
7778
78- if (Process:: isTtySupported ()) {
79- $ command ->setTty (true );
80- } else {
79+ try {
80+ $ command ->setTty ($ tty );
81+ } catch ( RuntimeException ) {
8182 $ output ->writeln (
8283 '<comment>Warning: TTY is not supported. The command may not display output as expected.</comment> '
8384 );
85+ $ tty = false ;
86+ }
8487
88+ if (! $ tty ) {
8589 $ callback = function (string $ type , string $ buffer ) use ($ output ): void {
8690 $ output ->write ($ buffer );
8791 };
8892 }
8993
9094 $ process = $ processHelper ->run (output: $ output , cmd: $ command , callback: $ callback );
9195
92- if (! $ process ->isSuccessful ()) {
93- $ output ->writeln (\sprintf (
94- '<error>Command "%s" failed with exit code %d. Please check the output above for details.</error> ' ,
95- $ command ->getCommandLine (),
96- $ command ->getExitCode ()
97- ));
98-
99- return self ::FAILURE ;
100- }
101-
102- return self ::SUCCESS ;
96+ return $ process ->isSuccessful () ? self ::SUCCESS : self ::FAILURE ;
10397 }
10498
10599 /**
0 commit comments