12
12
use Symfony \Component \Console \Input \InputOption ;
13
13
use Symfony \Component \Console \Output \OutputInterface ;
14
14
use Symfony \Component \Process \Exception \ProcessStartFailedException ;
15
+ use Symfony \Component \Console \Terminal ;
15
16
use Symfony \Component \Process \PhpExecutableFinder ;
16
17
use Symfony \Component \Process \Process ;
17
-
18
18
use function Laravel \Prompts \confirm ;
19
19
use function Laravel \Prompts \multiselect ;
20
20
use function Laravel \Prompts \select ;
@@ -892,13 +892,39 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
892
892
}, $ commands );
893
893
}
894
894
895
- $ commands = implode (' && ' , $ commands );
895
+ foreach ($ commands as $ command ) {
896
+ $ process = $ this ->runCommand ($ command , $ input , $ output , $ workingPath , $ env );
896
897
897
- if ($ this ->canUseSpinner ($ input , $ output )) {
898
- $ commands .= ' > /dev/null 2>&1 ' ;
898
+ if (! $ process ->isSuccessful ()) {
899
+ $ output ->writeln (' <bg=red;fg=white> ERROR </> ' .$ process ->getErrorOutput ().PHP_EOL );
900
+
901
+ break ;
902
+ }
899
903
}
900
904
901
- $ process = Process::fromShellCommandline ($ commands , $ workingPath , $ env , null , null );
905
+ return $ process ;
906
+ }
907
+
908
+ /**
909
+ * Run the given command.
910
+ *
911
+ * @param string $command
912
+ * @param InputInterface $input
913
+ * @param OutputInterface $output
914
+ * @param string|null $workingPath
915
+ * @param array $env
916
+ * @return \Symfony\Component\Process\Process
917
+ */
918
+ protected function runCommand (string $ command , InputInterface $ input , OutputInterface $ output , string $ workingPath = null , array $ env = [])
919
+ {
920
+ $ process = Process::fromShellCommandline ($ command , $ workingPath , $ env , null , null );
921
+
922
+ if ($ this ->canUseSpinner ($ input , $ output )) {
923
+ $ terminalWidth = (new Terminal )->getWidth ();
924
+ $ description = mb_substr ($ command , 0 , $ terminalWidth - 6 );
925
+
926
+ return spin (fn () => tap ($ process )->run (), "<fg=gray> {$ description }...</> " );
927
+ }
902
928
903
929
if ('\\' !== DIRECTORY_SEPARATOR && file_exists ('/dev/tty ' ) && is_readable ('/dev/tty ' )) {
904
930
try {
@@ -908,13 +934,7 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
908
934
}
909
935
}
910
936
911
- if ($ this ->canUseSpinner ($ input , $ output )) {
912
- return spin (fn () => tap ($ process )->run (), 'Installing... ' );
913
- }
914
-
915
- return tap ($ process )->run (function ($ type , $ line ) use ($ output ) {
916
- $ output ->write (' ' .$ line );
917
- });
937
+ return tap ($ process )->run ();
918
938
}
919
939
920
940
/**
0 commit comments