Add support for `all` option to `execaSync()` (#956)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent c15edbc · Browse files · 15 files·+323 added−166 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+323 added−166 removed
- tests:+213 added−89 removed
- other:+110 added−77 removed
Provenance
- Commit
63b5ac4- Tree
44b224a- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
c15edbc
15 files changed+323 added−166 removed
modified:lib/return/output.js+3 added-11 removed
1234567456791011121314158910115 unmodified linesimport stripFinalNewline from 'strip-final-newline';import {logFinalResult} from '../verbose/complete.js';
export const handleOutput = (options, value) => { if (value === undefined || value === null) { return; }export const stripNewline = (value, options) => options.stripFinalNewline && value !== undefined && !Array.isArray(value) ? stripFinalNewline(value) : value;
if (Array.isArray(value)) { return value; }
return options.stripFinalNewline ? stripFinalNewline(value) : value;};
export const handleResult = (result, verboseInfo, {reject}) => { logFinalResult(result, reject, verboseInfo);
if (result.failed && reject) {5 unmodified linesmodified:lib/stdio/output-sync.js+30 added-2 removed
12234569 unmodified lines1617181920202122232441 unmodified lines6667686970717273747576777879808182838485868788899091929394959697import {writeFileSync} from 'node:fs';import {joinToString, joinToUint8Array, bufferToUint8Array} from './uint-array.js';import {joinToString, joinToUint8Array, bufferToUint8Array, isUint8Array, concatUint8Arrays} from './uint-array.js';import {getGenerators, runGeneratorsSync} from './generator.js';import {FILE_TYPES} from './type.js';
// Apply `stdout`/`stderr` options, after spawning, in sync mode9 unmodified lines};
const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state}, {buffer, encoding, lines}) => { if (result === null) { return result; return; }
const selectedFileDescriptors = fileDescriptors.filter(fileDescriptor => fileDescriptor.fdNumber === fdNumber && fileDescriptor.direction === 'output'); const allStdioItems = selectedFileDescriptors.flatMap(({stdioItems}) => stdioItems);41 unmodified lines writeFileSync(path, serializedResult); } }};
export const getAllSync = ([, stdout, stderr], {all}) => { if (!all) { return; }
if (stdout === undefined) { return stderr; }
if (stderr === undefined) { return stdout; }
if (Array.isArray(stdout)) { return Array.isArray(stderr) ? [...stdout, ...stderr] : [...stdout, stderr]; }
if (Array.isArray(stderr)) { return [stdout, ...stderr]; }
if (isUint8Array(stdout) && isUint8Array(stderr)) { return concatUint8Arrays([stdout, stderr]); }
return `${stdout}${stderr}`;};modified:lib/stdio/uint-array.js+8 added-5 removed
31 unmodified lines32333435363637383940414243444546473 unmodified lines5152535448495051555657584 unmodified lines31 unmodified lines if (uint8ArraysOrStrings.length === 1 && isUint8Array(uint8ArraysOrStrings[0])) { return uint8ArraysOrStrings[0]; }
const uint8Arrays = stringsToUint8Arrays(uint8ArraysOrStrings); return concatUint8Arrays(stringsToUint8Arrays(uint8ArraysOrStrings));};
const stringsToUint8Arrays = uint8ArraysOrStrings => uint8ArraysOrStrings.map(uint8ArrayOrString => typeof uint8ArrayOrString === 'string' ? stringToUint8Array(uint8ArrayOrString) : uint8ArrayOrString);
export const concatUint8Arrays = uint8Arrays => { const result = new Uint8Array(getJoinLength(uint8Arrays));
let index = 0; for (const uint8Array of uint8Arrays) {3 unmodified lines
return result;};
const stringsToUint8Arrays = uint8ArraysOrStrings => uint8ArraysOrStrings.map(uint8ArrayOrString => typeof uint8ArrayOrString === 'string' ? stringToUint8Array(uint8ArrayOrString) : uint8ArrayOrString);
const getJoinLength = uint8Arrays => { let joinLength = 0; for (const uint8Array of uint8Arrays) { joinLength += uint8Array.length;4 unmodified linesmodified:lib/async.js+3 added-3 removed
1 import {setMaxListeners} from 'node:events';2 import {spawn} from 'node:child_process';3 import {handleCommand, handleOptions} from './arguments/options.js';4 import {makeError, makeSuccessResult} from './return/error.js';5-import {handleOutput, handleResult} from './return/output.js';5+import {stripNewline, handleResult} from './return/output.js';6 import {handleEarlyError} from './return/early-error.js';7 import {handleInputAsync, pipeOutputAsync} from './stdio/async.js';8 import {subprocessKill} from './exit/kill.js';9 import {cleanupOnExit} from './exit/cleanup.js';70 unmodified lines80 allResult,81 ] = await getSubprocessResult({subprocess, options, context, fileDescriptors, originalStreams, controller});82 controller.abort();83 84- const stdio = stdioResults.map(stdioResult => handleOutput(options, stdioResult));85- const all = handleOutput(options, allResult);84+ const stdio = stdioResults.map(stdioResult => stripNewline(stdioResult, options));85+ const all = stripNewline(allResult, options);86 const result = getAsyncResult({errorInfo, exitCode, signal, stdio, all, context, options, command, escapedCommand, startTime});87 return handleResult(result, verboseInfo, options);88 };89 16 unmodified linesmodified:lib/sync.js+8 added-6 removed
1 import {spawnSync} from 'node:child_process';2 import {handleCommand, handleOptions} from './arguments/options.js';3 import {makeError, makeEarlyError, makeSuccessResult} from './return/error.js';4-import {handleOutput, handleResult} from './return/output.js';4+import {stripNewline, handleResult} from './return/output.js';5 import {handleInputSync} from './stdio/sync.js';6 import {addInputOptionsSync} from './stdio/input-sync.js';7-import {transformOutputSync} from './stdio/output-sync.js';7+import {transformOutputSync, getAllSync} from './stdio/output-sync.js';8 import {logEarlyResult} from './verbose/complete.js';9 import {getSyncExitResult} from './exit/code.js';10 11 export const execaCoreSync = (rawFile, rawArgs, rawOptions) => {44 unmodified lines56 }57 58 const {resultError, exitCode, signal} = getSyncExitResult(syncResult);59 const {output, error = resultError} = transformOutputSync(fileDescriptors, syncResult, options);60- const stdio = output.map(stdioOutput => handleOutput(options, stdioOutput));61- return getSyncResult({error, exitCode, signal, stdio, options, command, escapedCommand, startTime});60+ const stdio = output.map(stdioOutput => stripNewline(stdioOutput, options));61+ const all = stripNewline(getAllSync(output, options), options);62+ return getSyncResult({error, exitCode, signal, stdio, all, options, command, escapedCommand, startTime});63 };64 65 const runSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {66 try {6 unmodified lines73 };74 75 const normalizeSpawnSyncOptions = ({encoding, ...options}) => ({...options, encoding: 'buffer'});76 76-const getSyncResult = ({error, exitCode, signal, stdio, options, command, escapedCommand, startTime}) => error === undefined77- ? makeSuccessResult({command, escapedCommand, stdio, options, startTime})77+const getSyncResult = ({error, exitCode, signal, stdio, all, options, command, escapedCommand, startTime}) => error === undefined78+ ? makeSuccessResult({command, escapedCommand, stdio, all, options, startTime})79 : makeError({80 error,81 command,82 escapedCommand,1 unmodified line84 isCanceled: false,85 exitCode,86 signal,87 stdio,88+ all,89 options,90 startTime,91 isSync: true,92 });added:test/fixtures/noop-both-fail-strict.js+8 added
12345678#!/usr/bin/env nodeimport process from 'node:process';
const stdoutBytes = process.argv[2];const stderrBytes = process.argv[3];process.stdout.write(stdoutBytes);process.stderr.write(stderrBytes);process.exitCode = 1;modified:test/fixtures/noop-both-fail.js+4 added-4 removed
123445675678#!/usr/bin/env nodeimport process from 'node:process';import {foobarString} from '../helpers/input.js';
const stdoutBytes = process.argv[2];const stderrBytes = process.argv[3];process.stdout.write(stdoutBytes);process.stderr.write(stderrBytes);const bytes = process.argv[2] || foobarString;console.log(bytes);console.error(bytes);process.exitCode = 1;modified:test/return/error.js+34 added-17 removed
9 unmodified lines10 const isWindows = process.platform === 'win32';11 12 setFixtureDir();13 14-test('Return value properties are not missing and are ordered', async t => {15- const result = await execa('empty.js', {...fullStdio, all: true});14+const testSuccessShape = async (t, execaMethod) => {15+ const result = await execaMethod('empty.js', {...fullStdio, all: true});16 t.deepEqual(Reflect.ownKeys(result), [17 'command',18 'escapedCommand',19 'cwd',8 unmodified lines28 'all',29 'stdio',30 'pipedFrom',31 ]);32-});32+};33 34-test('Error properties are not missing and are ordered', async t => {35- const error = await t.throwsAsync(execa('fail.js', {...fullStdio, all: true}));34+test('Return value properties are not missing and are ordered', testSuccessShape, execa);35+test('Return value properties are not missing and are ordered, sync', testSuccessShape, execaSync);36+37+const testErrorShape = async (t, execaMethod) => {38+ const error = await execaMethod('fail.js', {...fullStdio, all: true, reject: false});39+ t.is(error.exitCode, 2);40 t.deepEqual(Reflect.ownKeys(error), [41 'stack',42 'message',43 'shortMessage',15 unmodified lines59 'all',60 'stdio',61 'pipedFrom',62 ]);59-});63+};64 65+test('Error properties are not missing and are ordered', testErrorShape, execa);66+test('Error properties are not missing and are ordered, sync', testErrorShape, execaSync);67+68 test('error.message contains the command', async t => {69 await t.throwsAsync(execa('exit.js', ['2', 'foo', 'bar']), {message: /exit.js 2 foo bar/});70 });71 65-const testStdioMessage = async (t, encoding, all, objectMode) => {66- const {message} = await t.throwsAsync(execa('echo-fail.js', {...getStdio(1, noopGenerator(objectMode), 4), encoding, all}));72+// eslint-disable-next-line max-params73+const testStdioMessage = async (t, encoding, all, objectMode, execaMethod) => {74+ const {exitCode, message} = await execaMethod('echo-fail.js', {...getStdio(1, noopGenerator(objectMode), 4), encoding, all, reject: false});75+ t.is(exitCode, 1);76 const output = all ? 'stdout\nstderr' : 'stderr\n\nstdout';77 t.true(message.endsWith(`echo-fail.js\n\n${output}\n\nfd3`));78 };79 71-test('error.message contains stdout/stderr/stdio if available', testStdioMessage, 'utf8', false, false);72-test('error.message contains stdout/stderr/stdio even with encoding "buffer"', testStdioMessage, 'buffer', false, false);73-test('error.message contains all if available', testStdioMessage, 'utf8', true, false);74-test('error.message contains all even with encoding "buffer"', testStdioMessage, 'buffer', true, false);75-test('error.message contains stdout/stderr/stdio if available, objectMode', testStdioMessage, 'utf8', false, true);76-test('error.message contains stdout/stderr/stdio even with encoding "buffer", objectMode', testStdioMessage, 'buffer', false, true);77-test('error.message contains all if available, objectMode', testStdioMessage, 'utf8', true, true);78-test('error.message contains all even with encoding "buffer", objectMode', testStdioMessage, 'buffer', true, true);80+test('error.message contains stdout/stderr/stdio if available', testStdioMessage, 'utf8', false, false, execa);81+test('error.message contains stdout/stderr/stdio even with encoding "buffer"', testStdioMessage, 'buffer', false, false, execa);82+test('error.message contains all if available', testStdioMessage, 'utf8', true, false, execa);83+test('error.message contains all even with encoding "buffer"', testStdioMessage, 'buffer', true, false, execa);84+test('error.message contains stdout/stderr/stdio if available, objectMode', testStdioMessage, 'utf8', false, true, execa);85+test('error.message contains stdout/stderr/stdio even with encoding "buffer", objectMode', testStdioMessage, 'buffer', false, true, execa);86+test('error.message contains all if available, objectMode', testStdioMessage, 'utf8', true, true, execa);87+test('error.message contains all even with encoding "buffer", objectMode', testStdioMessage, 'buffer', true, true, execa);88+test('error.message contains stdout/stderr/stdio if available, sync', testStdioMessage, 'utf8', false, false, execaSync);89+test('error.message contains stdout/stderr/stdio even with encoding "buffer", sync', testStdioMessage, 'buffer', false, false, execaSync);90+test('error.message contains all if available, sync', testStdioMessage, 'utf8', true, false, execaSync);91+test('error.message contains all even with encoding "buffer", sync', testStdioMessage, 'buffer', true, false, execaSync);92+test('error.message contains stdout/stderr/stdio if available, objectMode, sync', testStdioMessage, 'utf8', false, true, execaSync);93+test('error.message contains stdout/stderr/stdio even with encoding "buffer", objectMode, sync', testStdioMessage, 'buffer', false, true, execaSync);94+test('error.message contains all if available, objectMode, sync', testStdioMessage, 'utf8', true, true, execaSync);95+test('error.message contains all even with encoding "buffer", objectMode, sync', testStdioMessage, 'buffer', true, true, execaSync);96 97 const testLinesMessage = async (t, encoding, stripFinalNewline, execaMethod) => {98 const {failed, message} = await execaMethod('noop-fail.js', ['1', `${foobarString}\n${foobarString}\n`], {99 lines: true,34 unmodified lines134 test('error.message does not contain stdout/stderr/stdio if not available', testFullIgnoreMessage, {stdio: 'ignore'}, 'message');135 test('error.shortMessage does not contain stdout/stderr/stdio', testFullIgnoreMessage, fullStdio, 'shortMessage');136 137 const testErrorMessageConsistent = async (t, stdout) => {121- const {message} = await t.throwsAsync(execa('noop-both-fail.js', [stdout, 'stderr']));138+ const {message} = await t.throwsAsync(execa('noop-both-fail-strict.js', [stdout, 'stderr']));139 t.true(message.endsWith(' stderr\n\nstderr\n\nstdout'));140 };141 142 test('error.message newlines are consistent - no newline', testErrorMessageConsistent, 'stdout');86 unmodified linesmodified:test/return/output.js+14 added-17 removed
64 unmodified lines65 66 test('undefined error.stdout/stderr/stdio', testUndefinedErrorStdio, execa);67 test('undefined error.stdout/stderr/stdio - sync', testUndefinedErrorStdio, execaSync);68 69-const testEmptyAll = async (t, options, expectedValue) => {70- const {all} = await t.throwsAsync(execa('fail.js', options));69+const testEmptyAll = async (t, options, expectedValue, execaMethod) => {70+ const {all} = await execaMethod('empty.js', options);71 t.is(all, expectedValue);72 };73 74-test('empty error.all', testEmptyAll, {all: true}, '');75-test('undefined error.all', testEmptyAll, {}, undefined);76-test('ignored error.all', testEmptyAll, {all: true, stdio: 'ignore'}, undefined);74+test('empty error.all', testEmptyAll, {all: true}, '', execa);75+test('undefined error.all', testEmptyAll, {}, undefined, execa);76+test('ignored error.all', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execa);77+test('empty error.all, sync', testEmptyAll, {all: true}, '', execaSync);78+test('undefined error.all, sync', testEmptyAll, {}, undefined, execaSync);79+test('ignored error.all, sync', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execaSync);80 81 test('empty error.stdio[0] even with input', async t => {82 const {stdio} = await t.throwsAsync(execa('fail.js', {input: 'test'}));83 t.is(stdio[0], undefined);1 unmodified line85 86 // `error.code` is OS-specific here87 const SPAWN_ERROR_CODES = new Set(['EINVAL', 'ENOTSUP', 'EPERM']);88 86-test('stdout/stderr/stdio on subprocess spawning errors', async t => {87- const {code, stdout, stderr, stdio} = await t.throwsAsync(execa('empty.js', {uid: -1}));89+const testSpawnError = async (t, execaMethod) => {90+ const {code, stdout, stderr, stdio, all} = await execaMethod('empty.js', {uid: -1, all: true, reject: false});91 t.true(SPAWN_ERROR_CODES.has(code));92 t.is(stdout, undefined);93 t.is(stderr, undefined);94+ t.is(all, undefined);95 t.deepEqual(stdio, [undefined, undefined, undefined]);92-});96+};97 94-test('stdout/stderr/all/stdio on subprocess spawning errors - sync', t => {95- const {code, stdout, stderr, stdio} = t.throws(() => {96- execaSync('empty.js', {uid: -1});97- });98- t.true(SPAWN_ERROR_CODES.has(code));99- t.is(stdout, undefined);100- t.is(stderr, undefined);101- t.deepEqual(stdio, [undefined, undefined, undefined]);102-});98+test('stdout/stderr/all/stdio on subprocess spawning errors', testSpawnError, execa);99+test('stdout/stderr/all/stdio on subprocess spawning errors - sync', testSpawnError, execaSync);100 101 const testErrorOutput = async (t, execaMethod) => {102 const {failed, stdout, stderr, stdio} = await execaMethod('echo-fail.js', {...fullStdio, reject: false});103 t.true(failed);36 unmodified linesmodified:test/stdio/generator.js+74 added-38 removed
447 unmodified lines448 : `${stdoutOutput}${stderrOutput}`;449 };450 451 // eslint-disable-next-line max-params452-const testGeneratorAll = async (t, reject, encoding, objectMode, stdoutOption, stderrOption) => {452+const testGeneratorAll = async (t, reject, encoding, objectMode, stdoutOption, stderrOption, execaMethod) => {453 const fixtureName = reject ? 'all.js' : 'all-fail.js';454- const {stdout, stderr, all} = await execa(fixtureName, {454+ const {stdout, stderr, all} = await execaMethod(fixtureName, {455 all: true,456 reject,457 stdout: getAllStdioOption(stdoutOption, encoding, objectMode),458 stderr: getAllStdioOption(stderrOption, encoding, objectMode),8 unmodified lines467 const allOutput = getAllOutput(stdoutOutput, stderrOutput, encoding, objectMode);468 t.deepEqual(all, allOutput);469 };470 471-test('Can use generators with result.all = transform + transform', testGeneratorAll, true, 'utf8', false, false, false);472-test('Can use generators with error.all = transform + transform', testGeneratorAll, false, 'utf8', false, false, false);473-test('Can use generators with result.all = transform + transform, encoding "buffer"', testGeneratorAll, true, 'buffer', false, false, false);474-test('Can use generators with error.all = transform + transform, encoding "buffer"', testGeneratorAll, false, 'buffer', false, false, false);475-test('Can use generators with result.all = transform + transform, encoding "hex"', testGeneratorAll, true, 'hex', false, false, false);476-test('Can use generators with error.all = transform + transform, encoding "hex"', testGeneratorAll, false, 'hex', false, false, false);477-test('Can use generators with result.all = transform + pipe', testGeneratorAll, true, 'utf8', false, false, true);478-test('Can use generators with error.all = transform + pipe', testGeneratorAll, false, 'utf8', false, false, true);479-test('Can use generators with result.all = transform + pipe, encoding "buffer"', testGeneratorAll, true, 'buffer', false, false, true);480-test('Can use generators with error.all = transform + pipe, encoding "buffer"', testGeneratorAll, false, 'buffer', false, false, true);481-test('Can use generators with result.all = transform + pipe, encoding "hex"', testGeneratorAll, true, 'hex', false, false, true);482-test('Can use generators with error.all = transform + pipe, encoding "hex"', testGeneratorAll, false, 'hex', false, false, true);483-test('Can use generators with result.all = pipe + transform', testGeneratorAll, true, 'utf8', false, true, false);484-test('Can use generators with error.all = pipe + transform', testGeneratorAll, false, 'utf8', false, true, false);485-test('Can use generators with result.all = pipe + transform, encoding "buffer"', testGeneratorAll, true, 'buffer', false, true, false);486-test('Can use generators with error.all = pipe + transform, encoding "buffer"', testGeneratorAll, false, 'buffer', false, true, false);487-test('Can use generators with result.all = pipe + transform, encoding "hex"', testGeneratorAll, true, 'hex', false, true, false);488-test('Can use generators with error.all = pipe + transform, encoding "hex"', testGeneratorAll, false, 'hex', false, true, false);489-test('Can use generators with result.all = transform + transform, objectMode', testGeneratorAll, true, 'utf8', true, false, false);490-test('Can use generators with error.all = transform + transform, objectMode', testGeneratorAll, false, 'utf8', true, false, false);491-test('Can use generators with result.all = transform + transform, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, false, false);492-test('Can use generators with error.all = transform + transform, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, false, false);493-test('Can use generators with result.all = transform + transform, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, false, false);494-test('Can use generators with error.all = transform + transform, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, false, false);495-test('Can use generators with result.all = transform + pipe, objectMode', testGeneratorAll, true, 'utf8', true, false, true);496-test('Can use generators with error.all = transform + pipe, objectMode', testGeneratorAll, false, 'utf8', true, false, true);497-test('Can use generators with result.all = transform + pipe, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, false, true);498-test('Can use generators with error.all = transform + pipe, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, false, true);499-test('Can use generators with result.all = transform + pipe, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, false, true);500-test('Can use generators with error.all = transform + pipe, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, false, true);501-test('Can use generators with result.all = pipe + transform, objectMode', testGeneratorAll, true, 'utf8', true, true, false);502-test('Can use generators with error.all = pipe + transform, objectMode', testGeneratorAll, false, 'utf8', true, true, false);503-test('Can use generators with result.all = pipe + transform, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, true, false);504-test('Can use generators with error.all = pipe + transform, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, true, false);505-test('Can use generators with result.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, true, false);506-test('Can use generators with error.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, true, false);471+test('Can use generators with result.all = transform + transform', testGeneratorAll, true, 'utf8', false, false, false, execa);472+test('Can use generators with error.all = transform + transform', testGeneratorAll, false, 'utf8', false, false, false, execa);473+test('Can use generators with result.all = transform + transform, encoding "buffer"', testGeneratorAll, true, 'buffer', false, false, false, execa);474+test('Can use generators with error.all = transform + transform, encoding "buffer"', testGeneratorAll, false, 'buffer', false, false, false, execa);475+test('Can use generators with result.all = transform + transform, encoding "hex"', testGeneratorAll, true, 'hex', false, false, false, execa);476+test('Can use generators with error.all = transform + transform, encoding "hex"', testGeneratorAll, false, 'hex', false, false, false, execa);477+test('Can use generators with result.all = transform + pipe', testGeneratorAll, true, 'utf8', false, false, true, execa);478+test('Can use generators with error.all = transform + pipe', testGeneratorAll, false, 'utf8', false, false, true, execa);479+test('Can use generators with result.all = transform + pipe, encoding "buffer"', testGeneratorAll, true, 'buffer', false, false, true, execa);480+test('Can use generators with error.all = transform + pipe, encoding "buffer"', testGeneratorAll, false, 'buffer', false, false, true, execa);481+test('Can use generators with result.all = transform + pipe, encoding "hex"', testGeneratorAll, true, 'hex', false, false, true, execa);482+test('Can use generators with error.all = transform + pipe, encoding "hex"', testGeneratorAll, false, 'hex', false, false, true, execa);483+test('Can use generators with result.all = pipe + transform', testGeneratorAll, true, 'utf8', false, true, false, execa);484+test('Can use generators with error.all = pipe + transform', testGeneratorAll, false, 'utf8', false, true, false, execa);485+test('Can use generators with result.all = pipe + transform, encoding "buffer"', testGeneratorAll, true, 'buffer', false, true, false, execa);486+test('Can use generators with error.all = pipe + transform, encoding "buffer"', testGeneratorAll, false, 'buffer', false, true, false, execa);487+test('Can use generators with result.all = pipe + transform, encoding "hex"', testGeneratorAll, true, 'hex', false, true, false, execa);488+test('Can use generators with error.all = pipe + transform, encoding "hex"', testGeneratorAll, false, 'hex', false, true, false, execa);489+test('Can use generators with result.all = transform + transform, objectMode', testGeneratorAll, true, 'utf8', true, false, false, execa);490+test('Can use generators with error.all = transform + transform, objectMode', testGeneratorAll, false, 'utf8', true, false, false, execa);491+test('Can use generators with result.all = transform + transform, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, false, false, execa);492+test('Can use generators with error.all = transform + transform, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, false, false, execa);493+test('Can use generators with result.all = transform + transform, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, false, false, execa);494+test('Can use generators with error.all = transform + transform, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, false, false, execa);495+test('Can use generators with result.all = transform + pipe, objectMode', testGeneratorAll, true, 'utf8', true, false, true, execa);496+test('Can use generators with error.all = transform + pipe, objectMode', testGeneratorAll, false, 'utf8', true, false, true, execa);497+test('Can use generators with result.all = transform + pipe, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, false, true, execa);498+test('Can use generators with error.all = transform + pipe, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, false, true, execa);499+test('Can use generators with result.all = transform + pipe, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, false, true, execa);500+test('Can use generators with error.all = transform + pipe, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, false, true, execa);501+test('Can use generators with result.all = pipe + transform, objectMode', testGeneratorAll, true, 'utf8', true, true, false, execa);502+test('Can use generators with error.all = pipe + transform, objectMode', testGeneratorAll, false, 'utf8', true, true, false, execa);503+test('Can use generators with result.all = pipe + transform, objectMode, encoding "buffer"', testGeneratorAll, true, 'buffer', true, true, false, execa);504+test('Can use generators with error.all = pipe + transform, objectMode, encoding "buffer"', testGeneratorAll, false, 'buffer', true, true, false, execa);505+test('Can use generators with result.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, true, 'hex', true, true, false, execa);506+test('Can use generators with error.all = pipe + transform, objectMode, encoding "hex"', testGeneratorAll, false, 'hex', true, true, false, execa);507+test('Can use generators with result.all = transform + transform, sync', testGeneratorAll, true, 'utf8', false, false, false, execaSync);508+test('Can use generators with error.all = transform + transform, sync', testGeneratorAll, false, 'utf8', false, false, false, execaSync);509+test('Can use generators with result.all = transform + transform, encoding "buffer", sync', testGeneratorAll, true, 'buffer', false, false, false, execaSync);510+test('Can use generators with error.all = transform + transform, encoding "buffer", sync', testGeneratorAll, false, 'buffer', false, false, false, execaSync);511+test('Can use generators with result.all = transform + transform, encoding "hex", sync', testGeneratorAll, true, 'hex', false, false, false, execaSync);512+test('Can use generators with error.all = transform + transform, encoding "hex", sync', testGeneratorAll, false, 'hex', false, false, false, execaSync);513+test('Can use generators with result.all = transform + pipe, sync', testGeneratorAll, true, 'utf8', false, false, true, execaSync);514+test('Can use generators with error.all = transform + pipe, sync', testGeneratorAll, false, 'utf8', false, false, true, execaSync);515+test('Can use generators with result.all = transform + pipe, encoding "buffer", sync', testGeneratorAll, true, 'buffer', false, false, true, execaSync);516+test('Can use generators with error.all = transform + pipe, encoding "buffer", sync', testGeneratorAll, false, 'buffer', false, false, true, execaSync);517+test('Can use generators with result.all = transform + pipe, encoding "hex", sync', testGeneratorAll, true, 'hex', false, false, true, execaSync);518+test('Can use generators with error.all = transform + pipe, encoding "hex", sync', testGeneratorAll, false, 'hex', false, false, true, execaSync);519+test('Can use generators with result.all = pipe + transform, sync', testGeneratorAll, true, 'utf8', false, true, false, execaSync);520+test('Can use generators with error.all = pipe + transform, sync', testGeneratorAll, false, 'utf8', false, true, false, execaSync);521+test('Can use generators with result.all = pipe + transform, encoding "buffer", sync', testGeneratorAll, true, 'buffer', false, true, false, execaSync);522+test('Can use generators with error.all = pipe + transform, encoding "buffer", sync', testGeneratorAll, false, 'buffer', false, true, false, execaSync);523+test('Can use generators with result.all = pipe + transform, encoding "hex", sync', testGeneratorAll, true, 'hex', false, true, false, execaSync);524+test('Can use generators with error.all = pipe + transform, encoding "hex", sync', testGeneratorAll, false, 'hex', false, true, false, execaSync);525+test('Can use generators with result.all = transform + transform, objectMode, sync', testGeneratorAll, true, 'utf8', true, false, false, execaSync);526+test('Can use generators with error.all = transform + transform, objectMode, sync', testGeneratorAll, false, 'utf8', true, false, false, execaSync);527+test('Can use generators with result.all = transform + transform, objectMode, encoding "buffer", sync', testGeneratorAll, true, 'buffer', true, false, false, execaSync);528+test('Can use generators with error.all = transform + transform, objectMode, encoding "buffer", sync', testGeneratorAll, false, 'buffer', true, false, false, execaSync);529+test('Can use generators with result.all = transform + transform, objectMode, encoding "hex", sync', testGeneratorAll, true, 'hex', true, false, false, execaSync);530+test('Can use generators with error.all = transform + transform, objectMode, encoding "hex", sync', testGeneratorAll, false, 'hex', true, false, false, execaSync);531+test('Can use generators with result.all = transform + pipe, objectMode, sync', testGeneratorAll, true, 'utf8', true, false, true, execaSync);532+test('Can use generators with error.all = transform + pipe, objectMode, sync', testGeneratorAll, false, 'utf8', true, false, true, execaSync);533+test('Can use generators with result.all = transform + pipe, objectMode, encoding "buffer", sync', testGeneratorAll, true, 'buffer', true, false, true, execaSync);534+test('Can use generators with error.all = transform + pipe, objectMode, encoding "buffer", sync', testGeneratorAll, false, 'buffer', true, false, true, execaSync);535+test('Can use generators with result.all = transform + pipe, objectMode, encoding "hex", sync', testGeneratorAll, true, 'hex', true, false, true, execaSync);536+test('Can use generators with error.all = transform + pipe, objectMode, encoding "hex", sync', testGeneratorAll, false, 'hex', true, false, true, execaSync);537+test('Can use generators with result.all = pipe + transform, objectMode, sync', testGeneratorAll, true, 'utf8', true, true, false, execaSync);538+test('Can use generators with error.all = pipe + transform, objectMode, sync', testGeneratorAll, false, 'utf8', true, true, false, execaSync);539+test('Can use generators with result.all = pipe + transform, objectMode, encoding "buffer", sync', testGeneratorAll, true, 'buffer', true, true, false, execaSync);540+test('Can use generators with error.all = pipe + transform, objectMode, encoding "buffer", sync', testGeneratorAll, false, 'buffer', true, true, false, execaSync);541+test('Can use generators with result.all = pipe + transform, objectMode, encoding "hex", sync', testGeneratorAll, true, 'hex', true, true, false, execaSync);542+test('Can use generators with error.all = pipe + transform, objectMode, encoding "hex", sync', testGeneratorAll, false, 'hex', true, true, false, execaSync);543 544 const testInputOption = async (t, type, execaMethod) => {545 const {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: generatorsMap[type].uppercase(), input: foobarUint8Array});546 t.is(stdout, foobarUppercase);152 unmodified linesmodified:test/stream/all.js+72 added-9 removed
1 import test from 'ava';2-import {execa} from '../../index.js';2+import {execa, execaSync} from '../../index.js';3 import {setFixtureDir} from '../helpers/fixtures-dir.js';4 import {defaultHighWaterMark} from '../helpers/stream.js';5+import {foobarString} from '../helpers/input.js';6 7 setFixtureDir();8 9+const textEncoder = new TextEncoder();10+const foobarStringFull = `${foobarString}\n`;11+const doubleFoobarStringFull = `${foobarStringFull}${foobarStringFull}`;12+const doubleFoobarString = `${foobarStringFull}${foobarString}`;13+const doubleFoobarUint8ArrayFull = textEncoder.encode(doubleFoobarStringFull);14+const doubleFoobarUint8Array = textEncoder.encode(doubleFoobarString);15+const doubleFoobarArrayFull = [foobarStringFull, foobarStringFull];16+const doubleFoobarArray = [foobarString, foobarString];17+18+// eslint-disable-next-line max-params19+const testAllBoth = async (t, expectedOutput, encoding, lines, stripFinalNewline, isFailure, execaMethod) => {20+ const fixtureName = isFailure ? 'noop-both-fail.js' : 'noop-both.js';21+ const {exitCode, all} = await execaMethod(fixtureName, [foobarString], {all: true, encoding, lines, stripFinalNewline, reject: !isFailure});22+ t.is(exitCode, isFailure ? 1 : 0);23+ t.deepEqual(all, expectedOutput);24+};25+26+test('result.all is defined', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, false, execa);27+test('result.all is defined, encoding "buffer"', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execa);28+test('result.all is defined, stripFinalNewline', testAllBoth, doubleFoobarString, 'utf8', false, true, false, execa);29+test('result.all is defined, encoding "buffer", stripFinalNewline', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, false, execa);30+test('result.all is defined, failure', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, true, execa);31+test('result.all is defined, encoding "buffer", failure', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execa);32+test('result.all is defined, stripFinalNewline, failure', testAllBoth, doubleFoobarString, 'utf8', false, true, true, execa);33+test('result.all is defined, encoding "buffer", stripFinalNewline, failure', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, true, execa);34+test('result.all is defined, sync', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, false, execaSync);35+test('result.all is defined, encoding "buffer", sync', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execaSync);36+test('result.all is defined, lines, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, false, execaSync);37+test('result.all is defined, stripFinalNewline, sync', testAllBoth, doubleFoobarString, 'utf8', false, true, false, execaSync);38+test('result.all is defined, encoding "buffer", stripFinalNewline, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, false, execaSync);39+test('result.all is defined, lines, stripFinalNewline, sync', testAllBoth, doubleFoobarArray, 'utf8', true, true, false, execaSync);40+test('result.all is defined, failure, sync', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, true, execaSync);41+test('result.all is defined, encoding "buffer", failure, sync', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execaSync);42+test('result.all is defined, lines, failure, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, true, execaSync);43+test('result.all is defined, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarString, 'utf8', false, true, true, execaSync);44+test('result.all is defined, encoding "buffer", stripFinalNewline, failure, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, true, execaSync);45+test('result.all is defined, lines, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', true, true, true, execaSync);46+47 test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {48 const {all} = await execa('noop-132.js', {all: true});49 t.is(all, '132');50 });51 13-test('result.all is undefined unless opts.all is true', async t => {14- const {all} = await execa('noop.js');15- t.is(all, undefined);52+test('result.all shows both `stdout` and `stderr` not intermixed, sync', t => {53+ const {all} = execaSync('noop-132.js', {all: true});54+ t.is(all, '123');55 });56 18-test('result.all is undefined if ignored', async t => {19- const {all} = await execa('noop.js', {stdio: 'ignore', all: true});57+const testAllIgnored = async (t, options, execaMethod) => {58+ const {all} = await execaMethod('noop.js');59 t.is(all, undefined);21-});60+};61 62+test('result.all is undefined unless opts.all is true', testAllIgnored, {}, execa);63+test('result.all is undefined if opts.all is false', testAllIgnored, {all: false}, execa);64+test('result.all is undefined if ignored', testAllIgnored, {stdio: 'ignore', all: true}, execa);65+test('result.all is undefined unless opts.all is true, sync', testAllIgnored, {}, execaSync);66+test('result.all is undefined if opts.all is false, sync', testAllIgnored, {all: false}, execaSync);67+test('result.all is undefined if ignored, sync', testAllIgnored, {stdio: 'ignore', all: true}, execaSync);68+69 const testAllProperties = async (t, options) => {70 const subprocess = execa('empty.js', {...options, all: true});71 t.is(subprocess.all.readableObjectMode, false);72 t.is(subprocess.all.readableHighWaterMark, defaultHighWaterMark);13 unmodified lines86 t.is(subprocess.all.readableHighWaterMark, subprocess[streamName].readableHighWaterMark);87 88 const result = await subprocess;89 t.is(result[otherStreamName], undefined);44- t.is(result[streamName], 'foobar');45- t.is(result.all, 'foobar');90+ t.is(result[streamName], foobarString);91+ t.is(result.all, foobarString);92 };93 94 test('can use all: true with stdout: ignore', testAllIgnore, 'stderr', 'stdout');95 test('can use all: true with stderr: ignore', testAllIgnore, 'stdout', 'stderr');96 97+const testAllIgnoreSync = (t, streamName, otherStreamName) => {98+ const result = execaSync('noop-both.js', {[otherStreamName]: 'ignore', all: true});99+ t.is(result[otherStreamName], undefined);100+ t.is(result[streamName], foobarString);101+ t.is(result.all, foobarString);102+};103+104+test('can use all: true with stdout: ignore, sync', testAllIgnoreSync, 'stderr', 'stdout');105+test('can use all: true with stderr: ignore, sync', testAllIgnoreSync, 'stdout', 'stderr');106+107 test('can use all: true with stdout: ignore + stderr: ignore', async t => {108 const subprocess = execa('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});109 t.is(subprocess.stdout, null);110 t.is(subprocess.stderr, null);3 unmodified lines114 t.is(stdout, undefined);115 t.is(stderr, undefined);116 t.is(all, undefined);117 });118+119+test('can use all: true with stdout: ignore + stderr: ignore, sync', t => {120+ const {stdout, stderr, all} = execaSync('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});121+ t.is(stdout, undefined);122+ t.is(stderr, undefined);123+ t.is(all, undefined);124+});modified:test/verbose/info.js+7 added-4 removed
1 import test from 'ava';2 import {setFixtureDir} from '../helpers/fixtures-dir.js';3-import {execa} from '../../index.js';3+import {execa, execaSync} from '../../index.js';4 import {foobarString} from '../helpers/input.js';5 import {6 QUOTE,7 nestedExecaAsync,5 unmodified lines13 } from '../helpers/verbose.js';14 15 setFixtureDir();16 17-test('Prints command, NODE_DEBUG=execa + "inherit"', async t => {18- const {all} = await execa('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});17+const testVerboseGeneral = async (t, execaMethod) => {18+ const {all} = await execaMethod('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});19 t.deepEqual(getNormalizedLines(all), [20 `${testTimestamp} [0] $ node -e ${QUOTE}console.error(1)${QUOTE}`,21 '1',22 `${testTimestamp} [0] √ (done in 0ms)`,23 `${testTimestamp} [1] $ node -e ${QUOTE}process.exit(2)${QUOTE}`,24 `${testTimestamp} [1] ‼ Command failed with exit code 2: node -e ${QUOTE}process.exit(2)${QUOTE}`,25 `${testTimestamp} [1] ‼ (done in 0ms)`,26 ]);27-});27+};28 29+test('Prints command, NODE_DEBUG=execa + "inherit"', testVerboseGeneral, execa);30+test('Prints command, NODE_DEBUG=execa + "inherit", sync', testVerboseGeneral, execaSync);31+32 test('NODE_DEBUG=execa changes verbose default value to "full"', async t => {33 const {stderr} = await nestedExecaAsync('noop.js', [foobarString], {}, {env: {NODE_DEBUG: 'execa'}});34 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);35 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);10 unmodified linesmodified:index.d.ts+9 added-9 removed
227 unmodified lines228 : IsInputStdioDescriptor<FdNumber, OptionsType> extends true229 ? true230 : IgnoresStreamResult<FdNumber, OptionsType>;231 232-type LacksBuffer<BufferOption extends Options['buffer']> = BufferOption extends false ? true : false;232+type LacksBuffer<BufferOption extends CommonOptions['buffer']> = BufferOption extends false ? true : false;233 234 // Whether `result.stdio[FdNumber]` is an input stream235 type IsInputStdioDescriptor<236 FdNumber extends string,70 unmodified lines307 : string[]308 : string;309 310 // Type of `result.all`311-type AllOutput<OptionsType extends Options = Options> = AllOutputProperty<OptionsType['all'], OptionsType>;311+type AllOutput<OptionsType extends CommonOptions = CommonOptions> = AllOutputProperty<OptionsType['all'], OptionsType>;312 313 type AllOutputProperty<314- AllOption extends Options['all'] = Options['all'],315- OptionsType extends Options = Options,314+ AllOption extends CommonOptions['all'] = CommonOptions['all'],315+ OptionsType extends CommonOptions = CommonOptions,316 > = AllOption extends true317 ? StdioOutput<AllUsesStdout<OptionsType> extends true ? '1' : '2', OptionsType>318 : undefined;319 320-type AllUsesStdout<OptionsType extends Options = Options> = IgnoresStreamOutput<'1', OptionsType> extends true320+type AllUsesStdout<OptionsType extends CommonOptions = CommonOptions> = IgnoresStreamOutput<'1', OptionsType> extends true321 ? false322 : IgnoresStreamOutput<'2', OptionsType> extends true323 ? true324 : IsObjectStream<'2', OptionsType> extends true356 unmodified lines681 Add an `.all` property on the promise and the resolved value. The property contains the output of the subprocess with `stdout` and `stderr` interleaved.682 683 @default false684 */685- readonly all?: Unless<IsSync, boolean>;685+ readonly all?: boolean;686 687 /**688 Enables exchanging messages with the subprocess using [`subprocess.send(value)`](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback) and [`subprocess.on('message', (value) => {})`](https://nodejs.org/api/child_process.html#event-message).689 154 unmodified lines844 - both `stdout` and `stderr` options are set to [`'inherit'`, `'ignore'`, `Stream` or `integer`](https://nodejs.org/api/child_process.html#child_process_options_stdio)845 846 This is an array if the `lines` option is `true`, or if either the `stdout` or `stderr` option is a transform in object mode.847 */848- all: Unless<IsSync, AllOutput<StricterOptions<OptionsType, Options>>>;848+ all: AllOutput<OptionsType>;849 850 /**851 Results of the other subprocesses that were piped into this subprocess. This is useful to inspect a series of subprocesses piped with each other.852 565 unmodified lines1418 Same as `execa()` but synchronous.1419 1420 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.1421 1422-Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1422+Cannot use the following options: `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. `result.all` is not interleaved. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1423 1424 @param file - The program/script to execute, as a string or file URL1425 @param arguments - Arguments to pass to `file` on execution.1426 @returns A `subprocessResult` object105 unmodified lines1532 Same as `execaCommand()` but synchronous.1533 1534 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.1535 1536-Cannot use the following options: `all`, `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1536+Cannot use the following options: `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. `result.all` is not interleaved. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'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.1537 1538 @param command - The program/script to execute and its arguments.1539 @returns A `subprocessResult` object1540 @throws A `subprocessResult` error128 unmodified linesmodified:index.test-d.ts+48 added-40 removed
171 unmodified lines172 expectType<AnyChunk>({} as ExecaResult['all']);173 expectAssignable<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>({} as ExecaResult['stdio']);174 expectType<AnyChunk>({} as ExecaSyncResult['stdout']);175 expectType<AnyChunk>({} as ExecaSyncResult['stderr']);176+expectType<AnyChunk>({} as ExecaSyncResult['all']);177 expectAssignable<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>({} as ExecaSyncResult['stdio']);178 179 try {180 const execaPromise = execa('unicorns', {all: true});910 unmodified lines1091 expectType<string | undefined>(noRejectsResult.code);1092 expectType<unknown>(noRejectsResult.cause);1093 1094 try {1094- const unicornsResult = execaSync('unicorns');1095+ const unicornsResult = execaSync('unicorns', {all: true});1096 1097 expectAssignable<ExecaSyncResult>(unicornsResult);1098 expectType<string>(unicornsResult.command);1099 expectType<string>(unicornsResult.escapedCommand);13 unmodified lines1113 expectType<string>(unicornsResult.stdout);1114 expectType<string>(unicornsResult.stdio[1]);1115 expectType<string>(unicornsResult.stderr);1116 expectType<string>(unicornsResult.stdio[2]);1116- expectError(unicornsResult.all.toString());1117+ expectType<string>(unicornsResult.all);1118 1118- const bufferResult = execaSync('unicorns', {encoding: 'buffer'});1119+ const bufferResult = execaSync('unicorns', {encoding: 'buffer', all: true});1120 expectType<Uint8Array>(bufferResult.stdout);1121 expectType<Uint8Array>(bufferResult.stdio[1]);1122 expectType<Uint8Array>(bufferResult.stderr);1123 expectType<Uint8Array>(bufferResult.stdio[2]);1123- expectError(bufferResult.all.toString());1124+ expectType<Uint8Array>(bufferResult.all);1125 1125- const linesResult = execaSync('unicorns', {lines: true});1126+ const linesResult = execaSync('unicorns', {lines: true, all: true});1127 expectType<string[]>(linesResult.stdout);1128 expectType<string[]>(linesResult.stderr);1129+ expectType<string[]>(linesResult.all);1130 1129- const linesBufferResult = execaSync('unicorns', {lines: true, encoding: 'buffer'});1131+ const linesBufferResult = execaSync('unicorns', {lines: true, encoding: 'buffer', all: true});1132 expectType<Uint8Array>(linesBufferResult.stdout);1133 expectType<Uint8Array>(linesBufferResult.stderr);1134+ expectType<Uint8Array>(linesBufferResult.all);1135 1133- const linesHexResult = execaSync('unicorns', {lines: true, encoding: 'hex'});1136+ const linesHexResult = execaSync('unicorns', {lines: true, encoding: 'hex', all: true});1137 expectType<string>(linesHexResult.stdout);1138 expectType<string>(linesHexResult.stderr);1139+ expectType<string>(linesHexResult.all);1140 1137- const noBufferResult = execaSync('unicorns', {buffer: false});1141+ const noBufferResult = execaSync('unicorns', {buffer: false, all: true});1142 expectType<undefined>(noBufferResult.stdout);1143 expectType<undefined>(noBufferResult.stderr);1144+ expectType<undefined>(noBufferResult.all);1145 1141- const ignoreStdoutResult = execaSync('unicorns', {stdout: 'ignore'});1146+ const ignoreStdoutResult = execaSync('unicorns', {stdout: 'ignore', all: true});1147 expectType<undefined>(ignoreStdoutResult.stdout);1148 expectType<undefined>(ignoreStdoutResult.stdio[1]);1149 expectType<string>(ignoreStdoutResult.stderr);1150 expectType<string>(ignoreStdoutResult.stdio[2]);1146- expectError(ignoreStdoutResult.all.toString());1151+ expectType<string>(ignoreStdoutResult.all);1152 1148- const ignoreStderrResult = execaSync('unicorns', {stderr: 'ignore'});1153+ const ignoreStderrResult = execaSync('unicorns', {stderr: 'ignore', all: true});1154 expectType<string>(ignoreStderrResult.stdout);1155 expectType<undefined>(ignoreStderrResult.stderr);1151- expectError(ignoreStderrResult.all.toString());1156+ expectType<string>(ignoreStderrResult.all);1157 1153- const inheritStdoutResult = execaSync('unicorns', {stdout: 'inherit'});1158+ const inheritStdoutResult = execaSync('unicorns', {stdout: 'inherit', all: true});1159 expectType<undefined>(inheritStdoutResult.stdout);1160 expectType<string>(inheritStdoutResult.stderr);1156- expectError(inheritStdoutResult.all.toString());1161+ expectType<string>(inheritStdoutResult.all);1162 1158- const inheritStderrResult = execaSync('unicorns', {stderr: 'inherit'});1163+ const inheritStderrResult = execaSync('unicorns', {stderr: 'inherit', all: true});1164 expectType<string>(inheritStderrResult.stdout);1165 expectType<undefined>(inheritStderrResult.stderr);1161- expectError(inheritStderrResult.all.toString());1166+ expectType<string>(inheritStderrResult.all);1167 1163- const numberStdoutResult = execaSync('unicorns', {stdout: 1});1168+ const numberStdoutResult = execaSync('unicorns', {stdout: 1, all: true});1169 expectType<undefined>(numberStdoutResult.stdout);1170 expectType<string>(numberStdoutResult.stderr);1166- expectError(numberStdoutResult.all.toString());1171+ expectType<string>(numberStdoutResult.all);1172 1168- const numberStderrResult = execaSync('unicorns', {stderr: 1});1173+ const numberStderrResult = execaSync('unicorns', {stderr: 1, all: true});1174 expectType<string>(numberStderrResult.stdout);1175 expectType<undefined>(numberStderrResult.stderr);1171- expectError(numberStderrResult.all.toString());1176+ expectType<string>(numberStderrResult.all);1177 } catch (error: unknown) {1178 if (error instanceof ExecaSyncError) {1179 expectAssignable<ExecaSyncError>(error);1180 expectType<'ExecaSyncError'>(error.name);13 unmodified lines1194 expectType<unknown>(error.cause);1195 expectType<[]>(error.pipedFrom);1196 }1197 1193- const execaStringError = error as ExecaSyncError<{}>;1198+ const execaStringError = error as ExecaSyncError<{all: true}>;1199 expectType<undefined>(execaStringError.stdio[0]);1200 expectType<string>(execaStringError.stdout);1201 expectType<string>(execaStringError.stdio[1]);1202 expectType<string>(execaStringError.stderr);1203 expectType<string>(execaStringError.stdio[2]);1199- expectError(execaStringError.all.toString());1204+ expectType<string>(execaStringError.all);1205 1201- const execaBufferError = error as ExecaSyncError<{encoding: 'buffer'}>;1206+ const execaBufferError = error as ExecaSyncError<{encoding: 'buffer'; all: true}>;1207 expectType<Uint8Array>(execaBufferError.stdout);1208 expectType<Uint8Array>(execaBufferError.stdio[1]);1209 expectType<Uint8Array>(execaBufferError.stderr);1210 expectType<Uint8Array>(execaBufferError.stdio[2]);1206- expectError(execaBufferError.all.toString());1211+ expectType<Uint8Array>(execaBufferError.all);1212 1208- const execaLinesError = error as ExecaSyncError<{lines: true}>;1213+ const execaLinesError = error as ExecaSyncError<{lines: true; all: true}>;1214 expectType<string[]>(execaLinesError.stdout);1215 expectType<string[]>(execaLinesError.stderr);1216+ expectType<string[]>(execaLinesError.all);1217 1212- const execaLinesBufferError = error as ExecaSyncError<{lines: true; encoding: 'buffer'}>;1218+ const execaLinesBufferError = error as ExecaSyncError<{lines: true; encoding: 'buffer'; all: true}>;1219 expectType<Uint8Array>(execaLinesBufferError.stdout);1220 expectType<Uint8Array>(execaLinesBufferError.stderr);1221+ expectType<Uint8Array>(execaLinesBufferError.all);1222 1216- const noBufferError = error as ExecaSyncError<{buffer: false}>;1223+ const noBufferError = error as ExecaSyncError<{buffer: false; all: true}>;1224 expectType<undefined>(noBufferError.stdout);1225 expectType<undefined>(noBufferError.stderr);1226+ expectType<undefined>(noBufferError.all);1227 1220- const ignoreStdoutError = error as ExecaSyncError<{stdout: 'ignore'}>;1228+ const ignoreStdoutError = error as ExecaSyncError<{stdout: 'ignore'; all: true}>;1229 expectType<undefined>(ignoreStdoutError.stdout);1230 expectType<undefined>(ignoreStdoutError.stdio[1]);1231 expectType<string>(ignoreStdoutError.stderr);1232 expectType<string>(ignoreStdoutError.stdio[2]);1225- expectError(ignoreStdoutError.all.toString());1233+ expectType<string>(ignoreStdoutError.all);1234 1227- const ignoreStderrError = error as ExecaSyncError<{stderr: 'ignore'}>;1235+ const ignoreStderrError = error as ExecaSyncError<{stderr: 'ignore'; all: true}>;1236 expectType<string>(ignoreStderrError.stdout);1237 expectType<undefined>(ignoreStderrError.stderr);1230- expectError(ignoreStderrError.all.toString());1238+ expectType<string>(ignoreStderrError.all);1239 1232- const inheritStdoutError = error as ExecaSyncError<{stdout: 'inherit'}>;1240+ const inheritStdoutError = error as ExecaSyncError<{stdout: 'inherit'; all: true}>;1241 expectType<undefined>(inheritStdoutError.stdout);1242 expectType<string>(inheritStdoutError.stderr);1235- expectError(inheritStdoutError.all.toString());1243+ expectType<string>(inheritStdoutError.all);1244 1237- const inheritStderrError = error as ExecaSyncError<{stderr: 'inherit'}>;1245+ const inheritStderrError = error as ExecaSyncError<{stderr: 'inherit'; all: true}>;1246 expectType<string>(inheritStderrError.stdout);1247 expectType<undefined>(inheritStderrError.stderr);1240- expectError(inheritStderrError.all.toString());1248+ expectType<string>(inheritStderrError.all);1249 1242- const numberStdoutError = error as ExecaSyncError<{stdout: 1}>;1250+ const numberStdoutError = error as ExecaSyncError<{stdout: 1; all: true}>;1251 expectType<undefined>(numberStdoutError.stdout);1252 expectType<string>(numberStdoutError.stderr);1245- expectError(numberStdoutError.all.toString());1253+ expectType<string>(numberStdoutError.all);1254 1247- const numberStderrError = error as ExecaSyncError<{stderr: 1}>;1255+ const numberStderrError = error as ExecaSyncError<{stderr: 1; all: true}>;1256 expectType<string>(numberStderrError.stdout);1257 expectType<undefined>(numberStderrError.stderr);1250- expectError(numberStderrError.all.toString());1258+ expectType<string>(numberStderrError.all);1259 }1260 1261 const rejectsSyncResult = execaSync('unicorns');1262 expectError(rejectsSyncResult.stack?.toString());144 unmodified lines1407 execaSync('unicorns', {buffer: false});1408 expectError(execa('unicorns', {buffer: 'false'}));1409 expectError(execaSync('unicorns', {buffer: 'false'}));1410 execa('unicorns', {all: true});1403-expectError(execaSync('unicorns', {all: true}));1411+execaSync('unicorns', {all: true});1412 expectError(execa('unicorns', {all: 'true'}));1413 expectError(execaSync('unicorns', {all: 'true'}));1414 execa('unicorns', {ipc: true});1415 expectError(execaSync('unicorns', {ipc: true}));2359 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), [`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 [`'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: [`cleanup`](#cleanup), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). [`result.all`](#all-1) is not interleaved. Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) options cannot be [`'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