Add support for `buffer: false` to `execaSync()` (#953)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 88bff1f · Browse files · 17 files·+182 added−43 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
17 files+182 added−43 removed
- tests:+151 added−30 removed
- other:+31 added−13 removed
Provenance
- Commit
d0052ac- Tree
b6ba810- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
88bff1f
17 files changed+182 added−43 removed
modified:lib/stdio/handle.js+1 added-1 removed
10 unmodified lines11121314151516171819115 unmodified linesExpand all10 unmodified lines
// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync modeexport const handleInput = (addProperties, options, verboseInfo, isSync) => { const stdioState = {}; const stdio = normalizeStdio(options); const stdio = normalizeStdio(options, isSync); const fileDescriptors = stdio.map((stdioOption, fdNumber) => getFileDescriptor({stdioOption, fdNumber, addProperties, options, isSync, stdioState, verboseInfo})); options.stdio = fileDescriptors.map(({stdioItems}) => forwardStdio(stdioItems)); return {fileDescriptors, stdioState};115 unmodified linesExpand allmodified:lib/stdio/option.js+13 added-4 removed
12344567867891028 unmodified lines394041424344454647484950515253import {STANDARD_STREAMS_ALIASES} from '../utils.js';
// Add support for `stdin`/`stdout`/`stderr` as an alias for `stdio`export const normalizeStdio = ({stdio, ipc, ...options}) => {export const normalizeStdio = ({stdio, ipc, buffer, verbose, ...options}, isSync) => { const stdioArray = getStdioArray(stdio, options).map((stdioOption, fdNumber) => addDefaultValue(stdioOption, fdNumber)); return ipc && !stdioArray.includes('ipc') ? [...stdioArray, 'ipc'] : stdioArray; return isSync ? normalizeStdioSync(stdioArray, buffer, verbose) : normalizeStdioAsync(stdioArray, ipc);};
const getStdioArray = (stdio, options) => { if (stdio === undefined) {28 unmodified lines }
return stdioOption;};
const normalizeStdioSync = (stdioArray, buffer, verbose) => buffer || verbose === 'full' ? stdioArray : stdioArray.map((stdioOption, fdNumber) => fdNumber !== 0 && isOutputPipeOnly(stdioOption) ? 'ignore' : stdioOption);
const isOutputPipeOnly = stdioOption => stdioOption === 'pipe' || (Array.isArray(stdioOption) && stdioOption.every(item => item === 'pipe'));
const normalizeStdioAsync = (stdioArray, ipc) => ipc && !stdioArray.includes('ipc') ? [...stdioArray, 'ipc'] : stdioArray;modified:lib/stdio/output-sync.js+4 added-3 removed
12 unmodified lines13 transformOutputResultSync({result, fileDescriptors, fdNumber, state}, options));14 return {output: transformedOutput, ...state};15 };16 17-const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state}, {encoding, lines}) => {17+const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state}, {buffer, encoding, lines}) => {18 if (result === null) {19 return result;20 }21 3 unmodified lines25 const uint8ArrayResult = bufferToUint8Array(result);26 const generators = getGenerators(allStdioItems);27 const chunks = runOutputGeneratorsSync([uint8ArrayResult], generators, state);28 const {serializedResult, finalResult} = serializeChunks({chunks, generators, allOutputLines, encoding, lines});29+ const returnedResult = buffer ? finalResult : undefined;30 31 try {32 if (state.error === undefined) {33 writeToFiles(serializedResult, allStdioItems);34 }35 35- return finalResult;36+ return returnedResult;37 } catch (error) {38 state.error = error;38- return finalResult;39+ return returnedResult;40 }41 };42 43 const runOutputGeneratorsSync = (chunks, generators, state) => {25 unmodified linesmodified:test/fixtures/nested-transform.js+8 added-3 removed
12334567878910111213#!/usr/bin/env nodeimport process from 'node:process';import {execa} from '../../index.js';import {execa, execaSync} from '../../index.js';import {generatorsMap} from '../helpers/map.js';
const [optionsString, file, ...args] = process.argv.slice(2);const {type, ...options} = JSON.parse(optionsString);await execa(file, args, {stdout: generatorsMap[type].uppercase(), ...options});const {type, isSync, ...options} = JSON.parse(optionsString);const newOptions = {stdout: generatorsMap[type].uppercase(), ...options};if (isSync === 'true') { execaSync(file, args, newOptions);} else { await execa(file, args, newOptions);}added:test/fixtures/nested-write.js+8 added
1+#!/usr/bin/env node2+import {writeFile} from 'node:fs/promises';3+import {text} from 'node:stream/consumers';4+import process from 'node:process';5+6+const [filePath, bytes] = process.argv.slice(2);7+const stdinString = await text(process.stdin);8+await writeFile(filePath, `${stdinString} ${bytes}`);modified:test/helpers/generator.js+2 added-1 removed
75 unmodified lines76 }77 });78 79 const textDecoder = new TextDecoder();80+const textEncoder = new TextEncoder();81 82 export const uppercaseBufferGenerator = getGenerator(function * (buffer) {82- yield textDecoder.decode(buffer).toUpperCase();83+ yield textEncoder.encode(textDecoder.decode(buffer).toUpperCase());84 });85 86 export const uppercaseGenerator = getGenerator(function * (string) {87 yield string.toUpperCase();26 unmodified linesmodified:test/helpers/input.js+2 added-1 removed
4 unmodified lines5 export const bufferToUint8Array = buffer => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);6 7 export const foobarString = 'foobar';8 export const foobarArray = ['foo', 'bar'];9-export const foobarUint8Array = textEncoder.encode('foobar');9+export const foobarUint8Array = textEncoder.encode(foobarString);10 export const foobarArrayBuffer = foobarUint8Array.buffer;11 export const foobarUint16Array = new Uint16Array(foobarArrayBuffer);12 export const foobarBuffer = Buffer.from(foobarString);13 const foobarUtf16Buffer = Buffer.from(foobarString, 'utf16le');14 export const foobarUtf16Uint8Array = bufferToUint8Array(foobarUtf16Buffer);15 export const foobarDataView = new DataView(foobarArrayBuffer);16 export const foobarHex = foobarBuffer.toString('hex');17 export const foobarUppercase = foobarString.toUpperCase();18+export const foobarUppercaseUint8Array = textEncoder.encode(foobarUppercase);19 export const foobarUppercaseHex = Buffer.from(foobarUppercase).toString('hex');20 export const foobarObject = {foo: 'bar'};21 export const foobarObjectString = JSON.stringify(foobarObject);modified:test/stdio/encoding-final.js+1 added-1 removed
17 unmodified lines18 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding});19 compareValues(t, stdio[fdNumber], encoding);20 21 if (execaMethod !== execaSync) {22- const subprocess = execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding, buffer: false});22+ const subprocess = execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding});23 const getStreamMethod = encoding === 'buffer' ? getStreamAsBuffer : getStream;24 const result = await getStreamMethod(subprocess.stdio[fdNumber]);25 compareValues(t, result, encoding);26 await subprocess;197 unmodified linesmodified:test/stdio/file-path.js+14 added
320 unmodified lines321 test('stderr can use "lines: true" together with output file URLs, sync', testOutputFileLines, 2, pathToFileURL, execaSync);322 test('stdio[*] can use "lines: true" together with output file paths, sync', testOutputFileLines, 3, getAbsolutePath, execaSync);323 test('stdio[*] can use "lines: true" together with output file URLs, sync', testOutputFileLines, 3, pathToFileURL, execaSync);324 325+const testOutputFileNoBuffer = async (t, execaMethod) => {326+ const filePath = tempfile();327+ const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {328+ stdout: getAbsolutePath(filePath),329+ buffer: false,330+ });331+ t.is(stdout, undefined);332+ t.is(await readFile(filePath, 'utf8'), foobarString);333+ await rm(filePath);334+};335+336+test('stdout can use "buffer: false" together with output file paths', testOutputFileNoBuffer, execa);337+test('stdout can use "buffer: false" together with output file paths, sync', testOutputFileNoBuffer, execaSync);338+339 const testOutputFileObject = async (t, fdNumber, mapFile, execaMethod) => {340 const filePath = tempfile();341 t.throws(() => {342 execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [52 unmodified linesmodified:test/stdio/lines.js+6 added-3 removed
127 unmodified lines128 test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline', testTextEncoding, noNewlinesChunks, true, execa);129 test('"lines: true" is a noop with "encoding: utf16", sync', testTextEncoding, simpleLines, false, execaSync);130 test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline, sync', testTextEncoding, noNewlinesChunks, true, execaSync);131 132-test('"lines: true" is a noop with "buffer: false"', async t => {133- const {stdout} = await getSimpleChunkSubprocessAsync({buffer: false});132+const testLinesNoBuffer = async (t, execaMethod) => {133+ const {stdout} = await getSimpleChunkSubprocess(execaMethod, {buffer: false});134 t.is(stdout, undefined);135-});135+};136 137+test('"lines: true" is a noop with "buffer: false"', testLinesNoBuffer, execa);138+test('"lines: true" is a noop with "buffer: false", sync', testLinesNoBuffer, execaSync);139+140 test('"lines: true" can be below "maxBuffer"', async t => {141 const maxBuffer = simpleLines.length;142 const {stdout} = await getSimpleChunkSubprocessAsync({maxBuffer});143 t.deepEqual(stdout, noNewlinesChunks);72 unmodified linesmodified:test/stdio/native.js+22 added-9 removed
1+import {readFile, rm} from 'node:fs/promises';2 import {platform} from 'node:process';3 import test from 'ava';4+import tempfile from 'tempfile';5 import {execa} from '../../index.js';6 import {getStdio, fullStdio} from '../helpers/stdio.js';7 import {setFixtureDir} from '../helpers/fixtures-dir.js';8+import {foobarString} from '../helpers/input.js';9 10 setFixtureDir();11 12 const testRedirect = async (t, stdioOption, fdNumber, isInput) => {13 const {fixtureName, ...options} = isInput11- ? {fixtureName: 'stdin-fd.js', input: 'foobar'}14+ ? {fixtureName: 'stdin-fd.js', input: foobarString}15 : {fixtureName: 'noop-fd.js'};13- const {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, fixtureName, 'foobar'], options);16+ const {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, fixtureName, foobarString], options);17 const resultFdNumber = isStderrDescriptor(stdioOption) ? 2 : 1;15- t.is(stdio[resultFdNumber], 'foobar');18+ t.is(stdio[resultFdNumber], foobarString);19 };20 21 const isStderrDescriptor = stdioOption => stdioOption === 222 || stdioOption === 'stderr'30 unmodified lines53 test('stdio[*] can be [process.stderr]', testRedirect, ['stderr'], 3, false);54 test('stdio[*] can be [process.stderr, "pipe"]', testRedirect, ['stderr', 'pipe'], 3, false);55 56 const testInheritStdin = async (t, stdin) => {54- const {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdin)], {input: 'foobar'});55- t.is(stdout, 'foobarfoobar');57+ const {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdin)], {input: foobarString});58+ t.is(stdout, `${foobarString}${foobarString}`);59 };60 61 test('stdin can be ["inherit", "pipe"]', testInheritStdin, ['inherit', 'pipe']);62 test('stdin can be [0, "pipe"]', testInheritStdin, [0, 'pipe']);63 64 const testInheritStdout = async (t, stdout) => {65 const result = await execa('nested-multiple-stdout.js', [JSON.stringify(stdout)]);63- t.is(result.stdout, 'foobar');64- t.is(result.stderr, 'nested foobar');66+ t.is(result.stdout, foobarString);67+ t.is(result.stderr, `nested ${foobarString}`);68 };69 70 test('stdout can be ["inherit", "pipe"]', testInheritStdout, ['inherit', 'pipe']);71 test('stdout can be [1, "pipe"]', testInheritStdout, [1, 'pipe']);72 73 const testInheritStderr = async (t, stderr) => {74 const result = await execa('nested-multiple-stderr.js', [JSON.stringify(stderr)]);72- t.is(result.stdout, 'nested foobar');73- t.is(result.stderr, 'foobar');75+ t.is(result.stdout, `nested ${foobarString}`);76+ t.is(result.stderr, foobarString);77 };78 79 test('stderr can be ["inherit", "pipe"]', testInheritStderr, ['inherit', 'pipe']);80 test('stderr can be [2, "pipe"]', testInheritStderr, [2, 'pipe']);81 82+const testInheritNoBuffer = async (t, stdioOption) => {83+ const filePath = tempfile();84+ await execa('nested.js', [JSON.stringify({stdin: stdioOption, buffer: false}), 'nested-write.js', filePath, foobarString], {input: foobarString});85+ t.is(await readFile(filePath, 'utf8'), `${foobarString} ${foobarString}`);86+ await rm(filePath);87+};88+89+test('stdin can be ["inherit", "pipe"], buffer: false', testInheritNoBuffer, ['inherit', 'pipe']);90+test('stdin can be [0, "pipe"], buffer: false', testInheritNoBuffer, [0, 'pipe']);91+92 const testOverflowStream = async (t, fdNumber, stdioOption) => {93 const {stdout} = await execa('nested.js', [JSON.stringify(getStdio(fdNumber, stdioOption)), 'empty.js'], fullStdio);94 t.is(stdout, '');95 };26 unmodified linesmodified:test/stream/max-buffer.js+11 added-1 removed
1 import {Buffer} from 'node:buffer';2 import test from 'ava';3 import getStream from 'get-stream';4-import {execa} from '../../index.js';4+import {execa, execaSync} from '../../index.js';5 import {setFixtureDir} from '../helpers/fixtures-dir.js';6 import {fullStdio} from '../helpers/stdio.js';7 8 setFixtureDir();71 unmodified lines80 test('do not buffer stdout when `buffer` set to `false`', testNoMaxBuffer, 1);81 test('do not buffer stderr when `buffer` set to `false`', testNoMaxBuffer, 2);82 test('do not buffer stdio[*] when `buffer` set to `false`', testNoMaxBuffer, 3);83 84+const testNoMaxBufferSync = (t, fdNumber) => {85+ const {stdio} = execaSync('max-buffer.js', [`${fdNumber}`, `${maxBuffer}`], {...fullStdio, buffer: false});86+ t.is(stdio[fdNumber], undefined);87+};88+89+// @todo: add a test for fd3 once the following Node.js bug is fixed.90+// https://github.com/nodejs/node/issues/5233891+test('do not buffer stdout when `buffer` set to `false`, sync', testNoMaxBufferSync, 1);92+test('do not buffer stderr when `buffer` set to `false`, sync', testNoMaxBufferSync, 2);93+94 const testNoMaxBufferOption = async (t, fdNumber) => {95 const length = maxBuffer + 1;96 const subprocess = execa('max-buffer.js', [`${fdNumber}`, `${length}`], {...fullStdio, maxBuffer, buffer: false});97 const [result, output] = await Promise.all([22 unmodified linesmodified:test/stream/no-buffer.js+60 added-8 removed
1 import {once} from 'node:events';2 import test from 'ava';3 import getStream from 'get-stream';4-import {execa} from '../../index.js';4+import {execa, execaSync} from '../../index.js';5 import {setFixtureDir} from '../helpers/fixtures-dir.js';6 import {fullStdio, getStdio} from '../helpers/stdio.js';7-import {foobarString} from '../helpers/input.js';7+import {foobarString, foobarUppercase, foobarUppercaseUint8Array} from '../helpers/input.js';8+import {resultGenerator, uppercaseGenerator, uppercaseBufferGenerator} from '../helpers/generator.js';9 10 setFixtureDir();11 12 const testLateStream = async (t, fdNumber, all) => {72 unmodified lines85 test('Listen to stderr errors even when `buffer` is `false`', testNoBufferStreamError, 2, false);86 test('Listen to stdio[*] errors even when `buffer` is `false`', testNoBufferStreamError, 3, false);87 test('Listen to all errors even when `buffer` is `false`', testNoBufferStreamError, 1, true);88 88-test('buffer: false > promise resolves', async t => {89- await t.notThrowsAsync(execa('noop.js', {buffer: false}));90-});89+const testNoOutput = async (t, stdioOption, execaMethod) => {90+ const {stdout} = await execaMethod('noop.js', {stdout: stdioOption, buffer: false});91+ t.is(stdout, undefined);92+};93 92-test('buffer: false > promise rejects when subprocess returns non-zero', async t => {93- const {exitCode} = await t.throwsAsync(execa('fail.js', {buffer: false}));94+test('buffer: false does not return output', testNoOutput, 'pipe', execa);95+test('buffer: false does not return output, stdout undefined', testNoOutput, undefined, execa);96+test('buffer: false does not return output, stdout null', testNoOutput, null, execa);97+test('buffer: false does not return output, stdout ["pipe"]', testNoOutput, ['pipe'], execa);98+test('buffer: false does not return output, stdout [undefined]', testNoOutput, [undefined], execa);99+test('buffer: false does not return output, stdout [null]', testNoOutput, [null], execa);100+test('buffer: false does not return output, stdout ["pipe", undefined]', testNoOutput, ['pipe', undefined], execa);101+test('buffer: false does not return output, sync', testNoOutput, 'pipe', execaSync);102+test('buffer: false does not return output, stdout undefined, sync', testNoOutput, undefined, execaSync);103+test('buffer: false does not return output, stdout null, sync', testNoOutput, null, execaSync);104+test('buffer: false does not return output, stdout ["pipe"], sync', testNoOutput, ['pipe'], execaSync);105+test('buffer: false does not return output, stdout [undefined], sync', testNoOutput, [undefined], execaSync);106+test('buffer: false does not return output, stdout [null], sync', testNoOutput, [null], execaSync);107+test('buffer: false does not return output, stdout ["pipe", undefined], sync', testNoOutput, ['pipe', undefined], execaSync);108+109+const testNoOutputFail = async (t, execaMethod) => {110+ const {exitCode, stdout} = await execaMethod('fail.js', {buffer: false, reject: false});111 t.is(exitCode, 2);112+ t.is(stdout, undefined);95-});113+};114 115+test('buffer: false does not return output, failure', testNoOutputFail, execa);116+test('buffer: false does not return output, failure, sync', testNoOutputFail, execaSync);117+118+const testTransform = async (t, objectMode, execaMethod) => {119+ const lines = [];120+ const {stdout} = await execaMethod('noop.js', {121+ buffer: false,122+ stdout: [uppercaseGenerator(objectMode), resultGenerator(lines)(objectMode)],123+ });124+ t.is(stdout, undefined);125+ t.deepEqual(lines, [foobarUppercase]);126+};127+128+test('buffer: false still runs transforms', testTransform, false, execa);129+test('buffer: false still runs transforms, objectMode', testTransform, true, execa);130+test('buffer: false still runs transforms, sync', testTransform, false, execaSync);131+test('buffer: false still runs transforms, objectMode, sync', testTransform, true, execaSync);132+133+const testTransformBinary = async (t, objectMode, execaMethod) => {134+ const lines = [];135+ const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {136+ buffer: false,137+ stdout: [uppercaseBufferGenerator(objectMode, true), resultGenerator(lines)(objectMode)],138+ encoding: 'buffer',139+ });140+ t.is(stdout, undefined);141+ t.deepEqual(lines, [foobarUppercaseUint8Array]);142+};143+144+test('buffer: false still runs transforms, encoding "buffer"', testTransformBinary, false, execa);145+test('buffer: false still runs transforms, encoding "buffer", objectMode', testTransformBinary, true, execa);146+test('buffer: false still runs transforms, encoding "buffer", sync', testTransformBinary, false, execaSync);147+test('buffer: false still runs transforms, encoding "buffer", objectMode, sync', testTransformBinary, true, execaSync);148+149 const testStreamEnd = async (t, fdNumber, buffer) => {150 const subprocess = execa('wrong command', {...fullStdio, buffer});151 await Promise.all([152 t.throwsAsync(subprocess, {message: /wrong command/}),10 unmodified linesmodified:test/verbose/output.js+17 added-3 removed
4 unmodified lines5 import tempfile from 'tempfile';6 import {red} from 'yoctocolors';7 import {execa} from '../../index.js';8 import {setFixtureDir} from '../helpers/fixtures-dir.js';9-import {foobarString, foobarObject} from '../helpers/input.js';9+import {foobarString, foobarObject, foobarUppercase} from '../helpers/input.js';10 import {fullStdio} from '../helpers/stdio.js';11 import {12 nestedExeca,13 nestedExecaAsync,222 unmodified lines236 test('Prints stdout, stdout "pipe"', testPrintOutputOptions, {stdout: 'pipe'}, nestedExecaAsync);237 test('Prints stdout, stdout "overlapped"', testPrintOutputOptions, {stdout: 'overlapped'}, nestedExecaAsync);238 test('Prints stdout, stdout null', testPrintOutputOptions, {stdout: null}, nestedExecaAsync);239 test('Prints stdout, stdout ["pipe"]', testPrintOutputOptions, {stdout: ['pipe']}, nestedExecaAsync);240-test('Prints stdout, buffer false', testPrintOutputOptions, {buffer: false}, nestedExecaAsync);240 test('Prints stdout, stdout "pipe", sync', testPrintOutputOptions, {stdout: 'pipe'}, nestedExecaSync);241 test('Prints stdout, stdout null, sync', testPrintOutputOptions, {stdout: null}, nestedExecaSync);242 test('Prints stdout, stdout ["pipe"], sync', testPrintOutputOptions, {stdout: ['pipe']}, nestedExecaSync);244-test('Prints stdout, buffer false, sync', testPrintOutputOptions, {buffer: false}, nestedExecaSync);243 244+const testPrintOutputNoBuffer = async (t, execaMethod) => {245+ const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'full', buffer: false});246+ t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);247+};248+249+test('Prints stdout, buffer: false', testPrintOutputNoBuffer, nestedExecaAsync);250+test('Prints stdout, buffer: false, sync', testPrintOutputNoBuffer, nestedExecaSync);251+252+const testPrintOutputNoBufferTransform = async (t, isSync) => {253+ const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', [foobarString], {verbose: 'full', buffer: false, type: 'generator', isSync});254+ t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarUppercase}`);255+};256+257+test('Prints stdout, buffer: false, transform', testPrintOutputNoBufferTransform, false);258+test('Prints stdout, buffer: false, transform, sync', testPrintOutputNoBufferTransform, true);259+260 const testPrintOutputFixture = async (t, fixtureName, ...args) => {261 const {stderr} = await nestedExeca(fixtureName, 'noop.js', [foobarString, ...args], {verbose: 'full'});262 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);263 };3 unmodified linesmodified:index.d.ts+3 added-3 removed
663 unmodified lines664 When `buffer` is `false`, the output can still be read using the `subprocess.stdout`, `subprocess.stderr`, `subprocess.stdio` and `subprocess.all` streams. If the output is read, this should be done right away to avoid missing any data.665 666 @default true667 */668- readonly buffer?: Unless<IsSync, boolean>;668+ readonly buffer?: boolean;669 670 /**671 Add an `.all` property on the promise and the resolved value. The property contains the output of the subprocess with `stdout` and `stderr` interleaved.672 735 unmodified lines1408 Same as `execa()` but synchronous.1409 1410 Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1411 1412-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1412+Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1413 1414 @param file - The program/script to execute, as a string or file URL1415 @param arguments - Arguments to pass to `file` on execution.1416 @returns A `subprocessResult` object105 unmodified lines1522 Same as `execaCommand()` but synchronous.1523 1524 Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1525 1526-Cannot use the following options: `all`, `cleanup`, `buffer`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1526+Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be a `['pipe', 'inherit']` array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1527 1528 @param command - The program/script to execute and its arguments.1529 @returns A `subprocessResult` object1530 @throws A `subprocessResult` error128 unmodified linesmodified:index.test-d.ts+9 added-1 removed
1132 unmodified lines1133 const linesHexResult = execaSync('unicorns', {lines: true, encoding: 'hex'});1134 expectType<string>(linesHexResult.stdout);1135 expectType<string>(linesHexResult.stderr);1136 1137+ const noBufferResult = execaSync('unicorns', {buffer: false});1138+ expectType<undefined>(noBufferResult.stdout);1139+ expectType<undefined>(noBufferResult.stderr);1140+1141 const ignoreStdoutResult = execaSync('unicorns', {stdout: 'ignore'});1142 expectType<undefined>(ignoreStdoutResult.stdout);1143 expectType<undefined>(ignoreStdoutResult.stdio[1]);1144 expectType<string>(ignoreStdoutResult.stderr);67 unmodified lines1212 const execaLinesBufferError = error as ExecaSyncError<{lines: true; encoding: 'buffer'}>;1213 expectType<Uint8Array>(execaLinesBufferError.stdout);1214 expectType<Uint8Array>(execaLinesBufferError.stderr);1215 1216+ const noBufferError = error as ExecaSyncError<{buffer: false}>;1217+ expectType<undefined>(noBufferError.stdout);1218+ expectType<undefined>(noBufferError.stderr);1219+1220 const ignoreStdoutError = error as ExecaSyncError<{stdout: 'ignore'}>;1221 expectType<undefined>(ignoreStdoutError.stdout);1222 expectType<undefined>(ignoreStdoutError.stdio[1]);1223 expectType<string>(ignoreStdoutError.stderr);171 unmodified lines1395 expectError(execaSync('unicorns', {cleanup: false}));1396 expectError(execa('unicorns', {cleanup: 'false'}));1397 expectError(execaSync('unicorns', {cleanup: 'false'}));1398 execa('unicorns', {buffer: false});1391-expectError(execaSync('unicorns', {buffer: false}));1399+execaSync('unicorns', {buffer: false});1400 expectError(execa('unicorns', {buffer: 'false'}));1401 expectError(execaSync('unicorns', {buffer: 'false'}));1402 execa('unicorns', {all: true});1403 expectError(execaSync('unicorns', {all: true}));2321 unmodified linesmodified:readme.md+1 added-1 removed
317 unmodified lines318 Same as [`execa()`](#execafile-arguments-options) but synchronous.319 320 Returns or throws a [`subprocessResult`](#subprocessResult). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipefile-arguments-options), [`.iterable()`](#iterablereadableoptions), [`.readable()`](#readablereadableoptions), [`.writable()`](#writablewritableoptions), [`.duplex()`](#duplexduplexoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.321 322-Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) cannot be a [`['pipe', 'inherit']`](#redirect-stdinstdoutstderr-to-multiple-destinations) array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.322+Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) cannot be a [`['pipe', 'inherit']`](#redirect-stdinstdoutstderr-to-multiple-destinations) array, [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.323 324 #### $(file, arguments?, options?)325 326 `file`: `string | URL`\899 unmodified lines