Skip to content
Myr

code.js

This file

Path

lib/exit/code.js

30 lines · 1.0 KiB · JavaScript

Last changed by

Allow setting different `maxBuffer` values for `stdout`/`stderr` (#966)ehmickybefore adoptionfdffcb6

History of this file

Take it

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 1why, one step back
1import {DiscardedError} from '../return/cause.js';

Allow setting different `maxBuffer` values for `stdout`/`stderr` (#966)ehmickybefore adoptionfdffcb6

line 2why, one step back
2import {isMaxBufferSync} from '../stream/max-buffer.js';

Split files (#837)ehmickybefore adoption672c2d7

lines 3–6why, one step back
3
4export const waitForSuccessfulExit = async exitPromise => {5 const [exitCode, signal] = await exitPromise;6

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 7why, one step back
7 if (!isSubprocessErrorExit(exitCode, signal) && isFailedExit(exitCode, signal)) {

Split files (#837)ehmickybefore adoption672c2d7

lines 8–13why, one step back
8 throw new DiscardedError();
9 }1011 return [exitCode, signal];12};13

Improve `maxBuffer` option with `execaSync()` (#960)ehmickybefore adoptiondce0393

lines 14–16why, one step back
14export const getSyncExitResult = ({error, status: exitCode, signal, output}, {maxBuffer}) => {
15 const resultError = getResultError(error, exitCode, signal);16 const timedOut = resultError?.code === 'ETIMEDOUT';

Allow setting different `maxBuffer` values for `stdout`/`stderr` (#966)ehmickybefore adoptionfdffcb6

line 17why, one step back
17 const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);

Improve `maxBuffer` option with `execaSync()` (#960)ehmickybefore adoptiondce0393

lines 18–19why, one step back
18 return {resultError, exitCode, signal, timedOut, isMaxBuffer};
19};

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 20why, one step back
20

Improve `maxBuffer` option with `execaSync()` (#960)ehmickybefore adoptiondce0393

line 21why, one step back
21const getResultError = (error, exitCode, signal) => {

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 22–28why, one step back
22 if (error !== undefined) {
23 return error;24 }2526 return isFailedExit(exitCode, signal) ? new DiscardedError() : undefined;27};28

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 29why, one step back
29const isSubprocessErrorExit = (exitCode, signal) => exitCode === undefined && signal === undefined;

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 30why, one step back
30const isFailedExit = (exitCode, signal) => exitCode !== 0 || signal !== null;