( command, args, execOpts, cmdDryRun = false )
| 94 | * @returns {Promise<any>} |
| 95 | */ |
| 96 | export async function spawnProcess( |
| 97 | command, |
| 98 | args, |
| 99 | execOpts, |
| 100 | cmdDryRun = false |
| 101 | ) { |
| 102 | if (cmdDryRun) { |
| 103 | return logExecDryRunCommand(command, args); |
| 104 | } |
| 105 | const child = x(command, args, execOpts); |
| 106 | const drain = (_code, signal) => { |
| 107 | children.delete(child); |
| 108 | |
| 109 | // don't run repeatedly if this is the error event |
| 110 | if (signal === undefined) { |
| 111 | child.process.removeListener('exit', drain); |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | child.process.once('exit', drain); |
| 116 | child.process.once('error', drain); |
| 117 | children.add(child); |
| 118 | |
| 119 | return child; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Spawn a command asynchronously, streaming stdio with optional prefix. |
no test coverage detected