exit-sync.js
This file
Path
lib/resolve/exit-sync.js
33 lines · 1.1 KiB · JavaScript
Last changed by
Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
line 1why, one step back1import {DiscardedError} from '../return/final-error.js';Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51
line 2why, one step back2import {handleMaxBufferSync} from '../io/max-buffer.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–5why, one step back3import {isFailedExit} from './exit-async.js';45// Retrieve exit code, signal name and error information, with synchronous methodsFix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51
lines 6–17why, one step back6export const getExitResultSync = ({error, status: exitCode, signal, output}, {maxBuffer, buffer}) => {7 const initialError = getResultError(error, exitCode, signal);8 const isTimedOut = initialError?.code === 'ETIMEDOUT';9 // A file descriptor over its `maxBuffer` does not stop the subprocess, so the timeout that did is reported instead. That file descriptor is still truncated.10 const {resultError, isMaxBuffer} = isTimedOut11 ? {resultError: initialError, isMaxBuffer: false}12 : handleMaxBufferSync({13 resultError: initialError,14 output,15 maxBuffer,16 buffer,17 });100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 18–21why, one step back18 return {19 resultError,20 exitCode,21 signal,Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 22why, one step back22 timedOut: isTimedOut,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 23–33why, one step back23 isMaxBuffer,24 };25};2627const getResultError = (error, exitCode, signal) => {28 if (error !== undefined) {29 return error;30 }3132 return isFailedExit(exitCode, signal) ? new DiscardedError() : undefined;33};