1111use Symfony \Component \Console \Input \InputInterface ;
1212use Symfony \Component \Console \Input \InputOption ;
1313use Symfony \Component \Console \Output \OutputInterface ;
14+ use Symfony \Component \Console \Terminal ;
1415use Symfony \Component \Process \PhpExecutableFinder ;
1516use Symfony \Component \Process \Process ;
16-
1717use function Laravel \Prompts \confirm ;
1818use function Laravel \Prompts \multiselect ;
1919use function Laravel \Prompts \select ;
@@ -887,13 +887,39 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
887887 }, $ commands );
888888 }
889889
890- $ commands = implode (' && ' , $ commands );
890+ foreach ($ commands as $ command ) {
891+ $ process = $ this ->runCommand ($ command , $ input , $ output , $ workingPath , $ env );
891892
892- if ($ this ->canUseSpinner ($ input , $ output )) {
893- $ commands .= ' > /dev/null 2>&1 ' ;
893+ if (! $ process ->isSuccessful ()) {
894+ $ output ->writeln (' <bg=red;fg=white> ERROR </> ' .$ process ->getErrorOutput ().PHP_EOL );
895+
896+ break ;
897+ }
894898 }
895899
896- $ process = Process::fromShellCommandline ($ commands , $ workingPath , $ env , null , null );
900+ return $ process ;
901+ }
902+
903+ /**
904+ * Run the given command.
905+ *
906+ * @param string $command
907+ * @param InputInterface $input
908+ * @param OutputInterface $output
909+ * @param string|null $workingPath
910+ * @param array $env
911+ * @return \Symfony\Component\Process\Process
912+ */
913+ protected function runCommand (string $ command , InputInterface $ input , OutputInterface $ output , string $ workingPath = null , array $ env = [])
914+ {
915+ $ process = Process::fromShellCommandline ($ command , $ workingPath , $ env , null , null );
916+
917+ if ($ this ->canUseSpinner ($ input , $ output )) {
918+ $ terminalWidth = (new Terminal )->getWidth ();
919+ $ description = mb_substr ($ command , 0 , $ terminalWidth - 6 );
920+
921+ return spin (fn () => tap ($ process )->run (), "<fg=gray> {$ description }...</> " );
922+ }
897923
898924 if ('\\' !== DIRECTORY_SEPARATOR && file_exists ('/dev/tty ' ) && is_readable ('/dev/tty ' )) {
899925 try {
@@ -903,13 +929,7 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
903929 }
904930 }
905931
906- if ($ this ->canUseSpinner ($ input , $ output )) {
907- return spin (fn () => tap ($ process )->run (), 'Installing... ' );
908- }
909-
910- return tap ($ process )->run (function ($ type , $ line ) use ($ output ) {
911- $ output ->write (' ' .$ line );
912- });
932+ return tap ($ process )->run ();
913933 }
914934
915935 /**
0 commit comments