(
command: string,
args: string[],
{cwd, env, shell}: RunOptions,
)
| 69 | } |
| 70 | |
| 71 | function run( |
| 72 | command: string, |
| 73 | args: string[], |
| 74 | {cwd, env, shell}: RunOptions, |
| 75 | ): void { |
| 76 | const commandLine = [command, ...args].join(' '); |
| 77 | console.log(`> ${commandLine} (in ${cwd})`); |
| 78 | const result = shell |
| 79 | ? spawnSync(commandLine, {cwd, env, stdio: 'inherit', shell: true}) |
| 80 | : spawnSync(command, args, {cwd, env, stdio: 'inherit'}); |
| 81 | if (result.error) { |
| 82 | throw new Error( |
| 83 | `Failed to start "${commandLine}" in ${cwd}: ${result.error.message}`, |
| 84 | ); |
| 85 | } |
| 86 | if (result.status !== 0) { |
| 87 | const exit = result.status ?? result.signal; |
| 88 | throw new Error(`"${commandLine}" in ${cwd} exited with ${exit}`); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // depot_tools uses `.bat` launchers on Windows, which only a shell can run. |
| 93 | // Callers pass fixed arguments without spaces, so joining them is safe. |
no outgoing calls
no test coverage detected