@@ -11,16 +11,26 @@ pub static FAILURE: Emoji<'_, '_> = Emoji("❌", "failed!");
11
11
12
12
/// Runs the given command conveniently, returning the exit code. Notably, this parses the given command by separating it on spaces.
13
13
/// Returns the command's output and the exit code.
14
- pub fn run_cmd ( raw_cmd : String , dir : & Path , pre_dump : impl Fn ( ) ) -> Result < ( String , String , i32 ) > {
15
- let mut cmd_args: Vec < & str > = raw_cmd. split ( ' ' ) . collect ( ) ;
16
- let cmd = cmd_args. remove ( 0 ) ;
14
+ pub fn run_cmd ( cmd : String , dir : & Path , pre_dump : impl Fn ( ) ) -> Result < ( String , String , i32 ) > {
15
+ // let mut cmd_args: Vec<&str> = raw_cmd.split(' ').collect();
16
+ // let cmd = cmd_args.remove(0);
17
+
18
+ // We run the command in a shell so that NPM/Yarn binaries can be recognized (see #5)
19
+ #[ cfg( unix) ]
20
+ let shell_exec = "sh" ;
21
+ #[ cfg( windows) ]
22
+ let shell_exec = "powershell" ;
23
+ #[ cfg( unix) ]
24
+ let shell_param = "-c" ;
25
+ #[ cfg( windows) ]
26
+ let shell_param = "-command" ;
17
27
18
28
// This will NOT pipe output/errors to the console
19
- let output = Command :: new ( & cmd )
20
- . args ( cmd_args )
29
+ let output = Command :: new ( shell_exec )
30
+ . args ( [ shell_param , & cmd ] )
21
31
. current_dir ( dir)
22
32
. output ( )
23
- . map_err ( |err| ErrorKind :: CmdExecFailed ( raw_cmd . clone ( ) , err. to_string ( ) ) ) ?;
33
+ . map_err ( |err| ErrorKind :: CmdExecFailed ( cmd . clone ( ) , err. to_string ( ) ) ) ?;
24
34
25
35
let exit_code = match output. status . code ( ) {
26
36
Some ( exit_code) => exit_code, // If we have an exit code, use it
0 commit comments