* Spawns a given command with the specified arguments inside an interactive shell. All process * stdin, stdout and stderr output is printed to the current console. * * @returns a Promise resolving on success, and rejecting on command failure with the status code.
(
command: string,
args: string[],
options: SpawnInteractiveCommandOptions = {},
)
| 64 | * @returns a Promise resolving on success, and rejecting on command failure with the status code. |
| 65 | */ |
| 66 | static spawnInteractive( |
| 67 | command: string, |
| 68 | args: string[], |
| 69 | options: SpawnInteractiveCommandOptions = {}, |
| 70 | ) { |
| 71 | return new Promise<void>((resolve, reject) => { |
| 72 | const commandText = `${command} ${args.join(' ')}`; |
| 73 | Log.debug(`Executing command: ${sanitize(commandText)}`); |
| 74 | const childProcess = _spawn(command, args, {...options, stdio: 'inherit'}); |
| 75 | // The `close` event is used because the process is guaranteed to have completed writing to |
| 76 | // stdout and stderr, using the `exit` event can cause inconsistent information in stdout and |
| 77 | // stderr due to a race condition around exiting. |
| 78 | childProcess.on('close', (status) => (status === 0 ? resolve() : reject(status))); |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Spawns a given command with the specified arguments inside a shell synchronously. |