code.js
This file
Path
lib/exit/code.js
14 lines · 494 bytes · JavaScript
Last changed by
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
History of this fileTake it
123456789101112131415import {DiscardedError} from '../return/error.js';
export const waitForSuccessfulExit = async exitPromise => { const [exitCode, signal] = await exitPromise;
if (!isSubprocessErrorExit(exitCode, signal) && isFailedExit(exitCode, signal)) { throw new DiscardedError(); }
return [exitCode, signal];};
const isSubprocessErrorExit = (exitCode, signal) => exitCode === undefined && signal === undefined;export const isFailedExit = (exitCode, signal) => exitCode !== 0 || signal !== null;