11
11
use Symfony \Component \Console \Input \InputInterface ;
12
12
use Symfony \Component \Console \Input \InputOption ;
13
13
use Symfony \Component \Console \Output \OutputInterface ;
14
+ use Symfony \Component \Console \Terminal ;
14
15
use Symfony \Component \Process \PhpExecutableFinder ;
15
16
use Symfony \Component \Process \Process ;
16
-
17
17
use function Laravel \Prompts \confirm ;
18
18
use function Laravel \Prompts \multiselect ;
19
19
use function Laravel \Prompts \select ;
@@ -887,13 +887,39 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
887
887
}, $ commands );
888
888
}
889
889
890
- $ commands = implode (' && ' , $ commands );
890
+ foreach ($ commands as $ command ) {
891
+ $ process = $ this ->runCommand ($ command , $ input , $ output , $ workingPath , $ env );
891
892
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
+ }
894
898
}
895
899
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
+ }
897
923
898
924
if ('\\' !== DIRECTORY_SEPARATOR && file_exists ('/dev/tty ' ) && is_readable ('/dev/tty ' )) {
899
925
try {
@@ -903,13 +929,7 @@ protected function runCommands($commands, InputInterface $input, OutputInterface
903
929
}
904
930
}
905
931
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 ();
913
933
}
914
934
915
935
/**
0 commit comments