@@ -23,7 +23,7 @@ import {
2323} from "node:fs" ;
2424import { createRequire } from "node:module" ;
2525import { tmpdir } from "node:os" ;
26- import { dirname , join , resolve } from "node:path" ;
26+ import { basename , dirname , join , resolve } from "node:path" ;
2727import { fileURLToPath } from "node:url" ;
2828
2929const repoRoot = resolve ( dirname ( fileURLToPath ( import . meta. url ) ) , ".." ) ;
@@ -75,12 +75,23 @@ function parseArgs(argv) {
7575
7676function run ( command , commandArgs , options = { } ) {
7777 const printable = [ command , ...commandArgs ] . join ( " " ) ;
78+ const shellCommands = new Set ( [ "pnpm" , "npm" , "npx" ] ) ;
79+ const commandLower = command . toLowerCase ( ) ;
80+ const usesShellOnWindows =
81+ process . platform === "win32" &&
82+ ( shellCommands . has ( basename ( command ) ) ||
83+ commandLower . endsWith ( ".cmd" ) ||
84+ commandLower . endsWith ( ".bat" ) ) ;
7885 console . log ( `\n[stage] $ ${ printable } ${ options . cwd ? ` (cwd=${ options . cwd } )` : "" } ` ) ;
7986 const result = spawnSync ( command , commandArgs , {
8087 stdio : "inherit" ,
8188 env : process . env ,
89+ shell : usesShellOnWindows ,
8290 ...options ,
8391 } ) ;
92+ if ( result . error ) {
93+ throw new Error ( `Command failed to start (${ result . error . message } ): ${ printable } ` ) ;
94+ }
8495 if ( result . status !== 0 ) {
8596 throw new Error ( `Command failed (${ result . status ?? "signal" } ): ${ printable } ` ) ;
8697 }
0 commit comments