Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent c631751 · Browse files · 19 files+280 added−49 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

19 files+280 added−49 removed

  • tests:+98 added−1 removed
  • other:+182 added−48 removed

19 files+280 added−49 removed

modified:lib/arguments/create.js+1 added-1 removed
modified:lib/arguments/options.js+3 added-5 removed
added:lib/arguments/specific.js+74 added
modified:lib/exit/code.js+2 added-3 removed
1import {DiscardedError} from '../return/cause.js';2import {isMaxBufferSync} from '../stream/max-buffer.js';34export const waitForSuccessfulExit = async exitPromise => {5 const [exitCode, signal] = await exitPromise;6
6 unmodified lines
1314export const getSyncExitResult = ({error, status: exitCode, signal, output}, {maxBuffer}) => {15 const resultError = getResultError(error, exitCode, signal);16 const timedOut = resultError?.code === 'ETIMEDOUT';16 const isMaxBuffer = resultError?.code === 'ENOBUFS'17 && output !== null18 && output.some(result => result !== null && result.length > maxBuffer);17 const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);18 return {resultError, exitCode, signal, timedOut, isMaxBuffer};19};2021const getResultError = (error, exitCode, signal) => {
9 unmodified lines
modified:lib/pipe/validate.js+4 added-14 removed
1import {normalizeArguments} from '../arguments/normalize.js';2import {STANDARD_STREAMS_ALIASES} from '../utils.js';2import {getStartTime} from '../return/duration.js';3import {serializeOptionValue} from '../stdio/native.js';4import {parseFd} from '../arguments/specific.js';56export const normalizePipeArguments = ({source, sourcePromise, boundOptions, createNested}, ...args) => {7 const startTime = getStartTime();8 const {
104 unmodified lines
113 return fdNumber;114};115116const parseFdNumber = (fdName, isWritable) => {117 if (fdName === 'all') {118 return fdName;117 const fdNumber = parseFd(fdName);118 if (fdNumber !== undefined) {119 return fdNumber;120 }121121 if (STANDARD_STREAMS_ALIASES.includes(fdName)) {122 return STANDARD_STREAMS_ALIASES.indexOf(fdName);123 }124125 const regexpResult = FD_REGEXP.exec(fdName);126 if (regexpResult !== null) {127 return Number(regexpResult[1]);128 }129122 const {validOptions, defaultValue} = isWritable123 ? {validOptions: '"stdin"', defaultValue: 'stdin'}124 : {validOptions: '"stdout", "stderr", "all"', defaultValue: 'stdout'};125 throw new TypeError(`"${getOptionName(isWritable)}" must not be "${fdName}".126It must be ${validOptions} or "fd3", "fd4" (and so on).127It is optional and defaults to "${defaultValue}".`);128};129138const FD_REGEXP = /^fd(\d+)$/;139130const validateFdNumber = (fdNumber, fdName, isWritable, fileDescriptors) => {131 const fileDescriptor = fileDescriptors[getUsedDescriptor(fdNumber)];132 if (fileDescriptor === undefined) {133 throw new TypeError(`"${getOptionName(isWritable)}" must not be ${fdName}. That file descriptor does not exist.
43 unmodified lines
modified:lib/stdio/handle.js+3 added-5 removed
1import {getStreamName} from '../utils.js';2import {getStdioItemType, isRegularUrl, isUnknownStdioString, FILE_TYPES} from './type.js';3import {getStreamDirection} from './direction.js';4import {normalizeStdio} from './option.js';5import {handleNativeStream} from './native.js';
12 unmodified lines
18// We make sure passing an array with a single item behaves the same as passing that item without an array.19// This is what users would expect.20// For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.21const getFileDescriptor = ({stdioOption, fdNumber, addProperties, options, isSync}) => {21 const optionName = getOptionName(fdNumber);22 const optionName = getStreamName(fdNumber);23 const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({stdioOption, fdNumber, options, optionName});24 const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);25 const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({stdioItem, isStdioArray, fdNumber, direction, isSync}));26 const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);27 const objectMode = getObjectMode(normalizedStdioItems, direction);28 validateFileObjectMode(normalizedStdioItems, objectMode);29 const finalStdioItems = normalizedStdioItems.map(stdioItem => addStreamProperties(stdioItem, addProperties, direction, options));29 return {streamName: optionName, direction, objectMode, stdioItems: finalStdioItems};30 return {direction, objectMode, stdioItems: finalStdioItems};31};3232const getOptionName = fdNumber => KNOWN_OPTION_NAMES[fdNumber] ?? `stdio[${fdNumber}]`;33const KNOWN_OPTION_NAMES = ['stdin', 'stdout', 'stderr'];3433const initializeStdioItems = ({stdioOption, fdNumber, options, optionName}) => {34 const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];35 const initialStdioItems = [36 ...values.map(value => initializeStdioItem(value, optionName)),
89 unmodified lines
modified:lib/stdio/output-sync.js+2 added-1 removed
1import {writeFileSync} from 'node:fs';2import {shouldLogOutput, logLinesSync} from '../verbose/output.js';3import {getMaxBufferSync} from '../stream/max-buffer.js';4import {joinToString, joinToUint8Array, bufferToUint8Array, isUint8Array, concatUint8Arrays} from './uint-array.js';5import {getGenerators, runGeneratorsSync} from './generator.js';6import {splitLinesSync} from './split.js';7import {FILE_TYPES} from './type.js';
14 unmodified lines
22 if (result === null) {23 return;24 }2525 const truncatedResult = truncateResult(result, isMaxBuffer, maxBuffer);26 const truncatedResult = truncateResult(result, isMaxBuffer, getMaxBufferSync(maxBuffer));27 const uint8ArrayResult = bufferToUint8Array(truncatedResult);28 const {stdioItems, objectMode} = fileDescriptors[fdNumber];29 const generators = getGenerators(stdioItems);30 const chunks = runOutputGeneratorsSync([uint8ArrayResult], generators, encoding, state);
89 unmodified lines
modified:lib/stream/all.js+1 added-1 removed
10 unmodified lines
11 stream: subprocess.all,12 fdNumber: 1,13 encoding,14 buffer,15 maxBuffer: maxBuffer * 2,15 maxBuffer: maxBuffer[1] + maxBuffer[2],16 lines,17 isAll: true,18 allMixed: getAllMixed(subprocess),19 stripFinalNewline,
12 unmodified lines
modified:lib/stream/max-buffer.js+22 added-9 removed
1import {MaxBufferError} from 'get-stream';2import {getStreamName} from '../utils.js';33export const handleMaxBuffer = ({error, stream, readableObjectMode, lines, encoding, streamName}) => {4export const handleMaxBuffer = ({error, stream, readableObjectMode, lines, encoding, fdNumber, isAll}) => {5 if (!(error instanceof MaxBufferError)) {5 return;6 throw error;7 }89 if (isAll) {10 return error;11 }1213 const unit = getMaxBufferUnit(readableObjectMode, lines, encoding);9 error.maxBufferInfo = {unit, streamName};14 error.maxBufferInfo = {fdNumber, unit};15 stream.destroy();16 throw error;17};1819const getMaxBufferUnit = (readableObjectMode, lines, encoding) => {20 if (readableObjectMode) {
11 unmodified lines
32 return 'characters';33};3435export const getMaxBufferMessage = (error, maxBuffer) => {30 const {unit, streamName} = getMaxBufferInfo(error);31 return `Command's ${streamName} was larger than ${maxBuffer} ${unit}`;36 const {streamName, threshold, unit} = getMaxBufferInfo(error, maxBuffer);37 return `Command's ${streamName} was larger than ${threshold} ${unit}`;38};3934const getMaxBufferInfo = error => {40const getMaxBufferInfo = (error, maxBuffer) => {41 if (error?.maxBufferInfo === undefined) {36 return {unit: 'bytes', streamName: 'output'};42 return {streamName: 'output', threshold: maxBuffer[1], unit: 'bytes'};43 }4439 const {maxBufferInfo} = error;45 const {maxBufferInfo: {fdNumber, unit}} = error;46 delete error.maxBufferInfo;41 return maxBufferInfo;47 return {streamName: getStreamName(fdNumber), threshold: maxBuffer[fdNumber], unit};48};4950export const isMaxBufferSync = (resultError, output, maxBuffer) => resultError?.code === 'ENOBUFS'51 && output !== null52 && output.some(result => result !== null && result.length > getMaxBufferSync(maxBuffer));5354// `spawnSync()` does not allow differentiating `maxBuffer` per file descriptor, so we always use `stdout`55export const getMaxBufferSync = maxBuffer => maxBuffer[1];
modified:lib/stream/resolve.js+1 added-1 removed
54 unmodified lines
55};5657// Read the contents of `subprocess.std*` and|or wait for its completion58const waitForSubprocessStreams = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) =>59 subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({stream, fdNumber, encoding, buffer, maxBuffer, lines, isAll: false, allMixed: false, stripFinalNewline, verboseInfo, streamInfo}));59 subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({stream, fdNumber, encoding, buffer, maxBuffer: maxBuffer[fdNumber], lines, isAll: false, allMixed: false, stripFinalNewline, verboseInfo, streamInfo}));6061// Transforms replace `subprocess.std*`, which means they are not exposed to users.62// However, we still want to wait for their completion.63const waitForOriginalStreams = (originalStreams, subprocess, streamInfo) =>
23 unmodified lines
modified:lib/stream/subprocess.js+3 added-5 removed
33 unmodified lines
34 return;35 }3637 const iterable = iterateForResult({stream, onStreamEnd, lines, encoding, stripFinalNewline, allMixed});38 return getStreamContents({stream, iterable, fdNumber, encoding, maxBuffer, lines, streamInfo});38 return getStreamContents({stream, iterable, fdNumber, encoding, maxBuffer, lines, isAll});39};4041// When using `buffer: false`, users need to read `subprocess.stdout|stderr|all` right away42// See https://github.com/sindresorhus/execa/issues/730 and https://github.com/sindresorhus/execa/pull/729#discussion_r1465496310
3 unmodified lines
46 stream.resume();47 }48};4950const getStreamContents = async ({stream, stream: {readableObjectMode}, iterable, fdNumber, encoding, maxBuffer, lines, streamInfo: {fileDescriptors}}) => {50const getStreamContents = async ({stream, stream: {readableObjectMode}, iterable, fdNumber, encoding, maxBuffer, lines, isAll}) => {51 try {52 if (readableObjectMode || lines) {53 return await getStreamAsArray(iterable, {maxBuffer});54 }
3 unmodified lines
58 }5960 return await getStream(iterable, {maxBuffer});61 } catch (error) {62 const {streamName} = fileDescriptors[fdNumber];63 handleMaxBuffer({error, stream, readableObjectMode, lines, encoding, maxBuffer, streamName});64 throw error;62 return handleBufferedData(handleMaxBuffer({error, stream, readableObjectMode, lines, encoding, fdNumber, isAll}));63 }64};6566// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
14 unmodified lines
modified:lib/sync.js+2 added-1 removed
5 unmodified lines
6import {addInputOptionsSync} from './stdio/input-sync.js';7import {transformOutputSync, getAllSync} from './stdio/output-sync.js';8import {logEarlyResult} from './verbose/complete.js';9import {getSyncExitResult} from './exit/code.js';10import {getMaxBufferSync} from './stream/max-buffer.js';1112export const execaCoreSync = (rawFile, rawArgs, rawOptions) => {13 const {file, args, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArgs, rawOptions);14 const result = spawnSubprocessSync({file, args, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime});
57 unmodified lines
72 return makeEarlyError({error, command, escapedCommand, fileDescriptors, options, startTime, isSync: true});73 }74};7575const normalizeSpawnSyncOptions = ({encoding, ...options}) => ({...options, encoding: 'buffer'});76const normalizeSpawnSyncOptions = ({encoding, maxBuffer, ...options}) => ({...options, encoding: 'buffer', maxBuffer: getMaxBufferSync(maxBuffer)});7778const getSyncResult = ({error, exitCode, signal, timedOut, isMaxBuffer, stdio, all, options, command, escapedCommand, startTime}) => error === undefined79 ? makeSuccessResult({command, escapedCommand, stdio, all, options, startTime})80 : makeError({
14 unmodified lines
modified:lib/utils.js+1 added
3 unmodified lines
45export const isStandardStream = stream => STANDARD_STREAMS.includes(stream);6export const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];7export const STANDARD_STREAMS_ALIASES = ['stdin', 'stdout', 'stderr'];8export const getStreamName = fdNumber => STANDARD_STREAMS_ALIASES[fdNumber] ?? `stdio[${fdNumber}]`;910export const incrementMaxListeners = (eventEmitter, maxListenersIncrement, signal) => {11 const maxListeners = eventEmitter.getMaxListeners();12 if (maxListeners === 0 || maxListeners === Number.POSITIVE_INFINITY) {
10 unmodified lines
modified:test/arguments/create.js+10 added
102 unmodified lines
103test('execaNode() bound options are merged multiple times', testMergeMultiple, execaNode);104test('$ bound options are merged multiple times', testMergeMultiple, $);105test('$.sync bound options are merged multiple times', testMergeMultiple, $.sync);106107const testMergeFdSpecific = async (t, execaMethod) => {108 const {isMaxBuffer, shortMessage} = await t.throwsAsync(execaMethod({maxBuffer: {stdout: 1}})(NOOP_PATH, [foobarString], {maxBuffer: {stderr: 100}}));109 t.true(isMaxBuffer);110 t.true(shortMessage.includes('Command\'s stdout was larger than 1'));111};112113test('execa() bound options merge fd-specific ones', testMergeFdSpecific, execa);114test('execaNode() bound options merge fd-specific ones', testMergeFdSpecific, execaNode);115test('$ bound options merge fd-specific ones', testMergeFdSpecific, $);116117const testMergeEnvUndefined = async (t, execaMethod) => {118 const {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: undefined}});119 t.is(stdout, 'foo\nundefined');120};
32 unmodified lines
modified:test/fixtures/noop-both.js+2 added-1 removed
1 unmodified line
2import process from 'node:process';3import {foobarString} from '../helpers/input.js';45const bytes = process.argv[2] || foobarString;6const bytesStderr = process.argv[3] || bytes;7console.log(bytes);7console.error(bytes);8console.error(bytesStderr);
modified:test/stream/max-buffer.js+86 added
85 unmodified lines
86test('maxBuffer truncates stderr, sync', testMaxBufferLimit, execaSync, 2, false);87test('maxBuffer truncates stdio[*], sync', testMaxBufferLimit, execaSync, 3, false);88test('maxBuffer truncates all, sync', testMaxBufferLimit, execaSync, 1, true);8990const MAX_BUFFER_DEFAULT = 1e8;9192const testMaxBufferDefault = async (t, execaMethod, fdNumber, maxBuffer) => {93 const length = MAX_BUFFER_DEFAULT;94 const {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {length: MAX_BUFFER_DEFAULT + 1, maxBuffer});95 assertErrorMessage(t, shortMessage, {execaMethod, fdNumber, length});96 t.is(stdio[fdNumber], getExpectedOutput(length));97};9899test('maxBuffer has a default value with stdout', testMaxBufferDefault, execa, 1, undefined);100test('maxBuffer has a default value with stderr', testMaxBufferDefault, execa, 2, undefined);101test('maxBuffer has a default value with stdio[*]', testMaxBufferDefault, execa, 3, undefined);102test('maxBuffer has a default value with stdout, sync', testMaxBufferDefault, execaSync, 1, undefined);103test('maxBuffer has a default value with stderr, sync', testMaxBufferDefault, execaSync, 2, undefined);104test('maxBuffer has a default value with stdio[*], sync', testMaxBufferDefault, execaSync, 3, undefined);105test('maxBuffer has a default value with stdout with fd-specific options', testMaxBufferDefault, execa, 1, {stderr: 1e9});106test('maxBuffer has a default value with stderr with fd-specific options', testMaxBufferDefault, execa, 2, {stdout: 1e9});107test('maxBuffer has a default value with stdio[*] with fd-specific options', testMaxBufferDefault, execa, 3, {stdout: 1e9});108test('maxBuffer has a default value with stdout with empty fd-specific options', testMaxBufferDefault, execa, 1, {});109110const testFdSpecific = async (t, fdNumber, fdName, execaMethod) => {111 const length = 1;112 const {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {maxBuffer: {[fdName]: length}});113 assertErrorMessage(t, shortMessage, {execaMethod, fdNumber, length});114 t.is(stdio[fdNumber], getExpectedOutput(length));115};116117test('maxBuffer truncates file descriptors with fd-specific options, stdout', testFdSpecific, 1, 'stdout', execa);118test('maxBuffer truncates file descriptors with fd-specific options, fd1', testFdSpecific, 1, 'fd1', execa);119test('maxBuffer truncates file descriptors with fd-specific options, stderr', testFdSpecific, 2, 'stderr', execa);120test('maxBuffer truncates file descriptors with fd-specific options, fd2', testFdSpecific, 2, 'fd2', execa);121test('maxBuffer truncates file descriptors with fd-specific options, stdout, all', testFdSpecific, 1, 'all', execa);122test('maxBuffer truncates file descriptors with fd-specific options, stderr, all', testFdSpecific, 2, 'all', execa);123test('maxBuffer truncates file descriptors with fd-specific options, fd3', testFdSpecific, 3, 'fd3', execa);124test('maxBuffer.stdout is used for stdout with fd-specific options, stdout, sync', testFdSpecific, 1, 'stdout', execaSync);125126test('maxBuffer does not affect other file descriptors with fd-specific options', async t => {127 const {isMaxBuffer} = await getMaxBufferSubprocess(execa, 2, {maxBuffer: {stdout: 1}});128 t.false(isMaxBuffer);129});130131test('maxBuffer.stdout is used for other file descriptors with fd-specific options, sync', async t => {132 const length = 1;133 const {shortMessage, stderr} = await runMaxBuffer(t, execaSync, 2, {maxBuffer: {stdout: length}});134 assertErrorMessage(t, shortMessage, {execaMethod: execaSync, fdNumber: 2, length});135 t.is(stderr, getExpectedOutput(length));136});137138const testAll = async (t, shouldFail) => {139 const difference = shouldFail ? 0 : 1;140 const maxBufferStdout = 2;141 const maxBufferStderr = 4 - difference;142 const {isMaxBuffer, shortMessage, stdout, stderr, all} = await execa(143 'noop-both.js',144 ['\n'.repeat(maxBufferStdout - 1), '\n'.repeat(maxBufferStderr - difference)],145 {maxBuffer: {stdout: maxBufferStdout, stderr: maxBufferStderr}, all: true, stripFinalNewline: false, reject: false},146 );147 t.is(isMaxBuffer, shouldFail);148 if (shouldFail) {149 assertErrorMessage(t, shortMessage, {fdNumber: 2, length: maxBufferStderr});150 }151152 t.is(stdout, '\n'.repeat(maxBufferStdout));153 t.is(stderr, '\n'.repeat(maxBufferStderr));154 t.is(all, '\n'.repeat(maxBufferStdout + maxBufferStderr));155};156157test('maxBuffer.stdout can differ from maxBuffer.stderr, combined with all, below threshold', testAll, false);158test('maxBuffer.stdout can differ from maxBuffer.stderr, combined with all, above threshold', testAll, true);159160const testInvalidFd = async (t, fdName, execaMethod) => {161 const {message} = t.throws(() => {162 execaMethod('empty.js', {maxBuffer: {[fdName]: 0}});163 });164 t.true(message.includes(`"maxBuffer.${fdName}" is invalid`));165};166167test('maxBuffer.stdin is invalid', testInvalidFd, 'stdin', execa);168test('maxBuffer.fd0 is invalid', testInvalidFd, 'fd0', execa);169test('maxBuffer.other is invalid', testInvalidFd, 'other', execa);170test('maxBuffer.fd10 is invalid', testInvalidFd, 'fd10', execa);171test('maxBuffer.stdin is invalid, sync', testInvalidFd, 'stdin', execaSync);172test('maxBuffer.fd0 is invalid, sync', testInvalidFd, 'fd0', execaSync);173test('maxBuffer.other is invalid, sync', testInvalidFd, 'other', execaSync);174test('maxBuffer.fd10 is invalid, sync', testInvalidFd, 'fd10', execaSync);175176const testMaxBufferEncoding = async (t, execaMethod, fdNumber) => {177 const {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {encoding: 'buffer'});178 assertErrorMessage(t, shortMessage, {execaMethod, fdNumber, unit: 'bytes'});179 const stream = stdio[fdNumber];
81 unmodified lines
modified:index.d.ts+32 added-1 removed
354 unmodified lines
355 WideOptions extends CommonOptions,356 StrictOptions extends CommonOptions,357> = WideOptions extends StrictOptions ? WideOptions : StrictOptions;358359type FdGenericOption<OptionType> = OptionType | {360 readonly [FdName in FromOption]?: OptionType361};362363type CommonOptions<IsSync extends boolean = boolean> = {364 /**365 Prefer locally installed binaries when looking for a binary to execute.366
232 unmodified lines
599 - If the `encoding` option is `'buffer'`: in bytes.600 - If the `lines` option is `true`: in lines.601 - If a transform in object mode is used: in objects.602603 By default, this applies to both `stdout` and `stderr`, but different values can also be passed.604605 @default 100_000_000606 */601 readonly maxBuffer?: number;607 readonly maxBuffer?: FdGenericOption<number>;608609 /**610 Signal used to terminate the subprocess when:611 - using the `cancelSignal`, `timeout`, `maxBuffer` or `cleanup` option
131 unmodified lines
743 */744 readonly cancelSignal?: Unless<IsSync, AbortSignal>;745};746747/**748Subprocess options.749750Some options are related to the subprocess output: `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.751752@example753754```755await execa('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr756await execa('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values757```758*/759export type Options = CommonOptions<false>;760761/**762Subprocess options, with synchronous methods.763764Some options are related to the subprocess output: `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.765766@example767768```769execaSync('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr770execaSync('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values771```772*/773export type SyncOptions = CommonOptions<true>;774775declare abstract class CommonResult<776 IsSync extends boolean = boolean,
950 unmodified lines
modified:index.test-d.ts+21 added
1467 unmodified lines
1468execaSync('unicorns', {encoding: 'ascii'});1469expectError(execa('unicorns', {encoding: 'unknownEncoding'}));1470expectError(execaSync('unicorns', {encoding: 'unknownEncoding'}));14711472execa('unicorns', {maxBuffer: {}});1473expectError(execa('unicorns', {maxBuffer: []}));1474execa('unicorns', {maxBuffer: {stdout: 0}});1475execa('unicorns', {maxBuffer: {stderr: 0}});1476execa('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});1477execa('unicorns', {maxBuffer: {all: 0}});1478execa('unicorns', {maxBuffer: {fd1: 0}});1479execa('unicorns', {maxBuffer: {fd2: 0}});1480execa('unicorns', {maxBuffer: {fd3: 0}});1481expectError(execa('unicorns', {maxBuffer: {stdout: '0'}}));1482execaSync('unicorns', {maxBuffer: {}});1483expectError(execaSync('unicorns', {maxBuffer: []}));1484execaSync('unicorns', {maxBuffer: {stdout: 0}});1485execaSync('unicorns', {maxBuffer: {stderr: 0}});1486execaSync('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});1487execaSync('unicorns', {maxBuffer: {all: 0}});1488execaSync('unicorns', {maxBuffer: {fd1: 0}});1489execaSync('unicorns', {maxBuffer: {fd2: 0}});1490execaSync('unicorns', {maxBuffer: {fd3: 0}});1491expectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));14921493expectError(execa('unicorns', {stdio: []}));1494expectError(execaSync('unicorns', {stdio: []}));1495expectError(execa('unicorns', {stdio: ['pipe']}));1496expectError(execaSync('unicorns', {stdio: ['pipe']}));
2303 unmodified lines
modified:readme.md+10 added-1 removed
752 unmodified lines
753### options754755Type: `object`756757This lists all Execa options, including some options which are the same as for [`child_process#spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)/[`child_process#exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).757This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).758759Some options are related to the subprocess output: [`maxBuffer`](#maxbuffer). By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `fd3`, etc.760761```js762await execa('./run.js', {maxBuffer: 1e6}) // Same value for stdout and stderr763await execa('./run.js', {maxBuffer: {stdout: 1e4, stderr: 1e6}}) // Different values764```765766#### reject767768Type: `boolean`\769Default: `true`
246 unmodified lines
1016- If the [`encoding` option](#encoding) is `'buffer'`: in bytes.1017- If the [`lines` option](#lines) is `true`: in lines.1018- If a [transform in object mode](docs/transform.md#object-mode) is used: in objects.10191020By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](#options).10211022#### ipc10231024Type: `boolean`\1025Default: `true` if the [`node`](#node) option is enabled, `false` otherwise
227 unmodified lines