diff --git a/lib/exec.js b/lib/exec.js index 79fd1100c..a5da77669 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -26,14 +26,15 @@ export const exec = async (file, args, options) => { const program = spawn(file, args, { cwd: options?.cwd }) - pipeline(program.stdout, pipeToBuffer) - pipeline(program.stderr, pipeToBuffer) - - const [exitCode] = await once(program, 'exit') + await Promise.allSettled([ + pipeline(program.stdout, pipeToBuffer), + pipeline(program.stderr, pipeToBuffer), + once(program, 'exit'), + ]) const output = buffer.reduce((result, chunk) => result + chunk, '').replace(/\n$/, '') - if (exitCode !== 0) { + if (program.exitCode !== 0) { throw new Error(output) }