Fix fd-specific options to account for `ipc` (#1241)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by GitHub · parent 68986b7 · Browse files · 12 files·+135 added−56 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
12 files+135 added−56 removed
- tests:+89 added−20 removed
- other:+46 added−36 removed
Provenance
- Commit
b886883- Tree
21c9b95- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
68986b7
12 files changed+135 added−56 removed
modified:lib/arguments/specific.js+10 added-9 removed
14 unmodified lines1516171819192020212223242526272828292930313232333434353637383910 unmodified lines505152535354555556575859606162636464656667686943 unmodified lines14 unmodified lines return optionsCopy;};
export const normalizeFdSpecificOption = (options, optionName) => { const stdioLength = getStdioLength(options); const optionBaseArray = Array.from({length: getStdioLength(options) + 1}); const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName); const optionBaseArray = Array.from({length: stdioLength + 1}); const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName, stdioLength); return addDefaultValue(optionArray, optionName);};
const getStdioLength = ({stdio}) => Array.isArray(stdio) ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length) : STANDARD_STREAMS_ALIASES.length;
const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName)const normalizeFdSpecificValue = (optionValue, optionArray, optionName, stdioLength) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName, stdioLength) : optionArray.fill(optionValue);
const normalizeOptionObject = (optionValue, optionArray, optionName) => {const normalizeOptionObject = (optionValue, optionArray, optionName, stdioLength) => { for (const fdName of Object.keys(optionValue).sort(compareFdName)) { for (const fdNumber of parseFdName(fdName, optionName, optionArray)) { for (const fdNumber of parseFdName(fdName, optionName, stdioLength)) { optionArray[fdNumber] = optionValue[fdName]; } }
10 unmodified lines
return fdName === 'all' ? 2 : 1;};
const parseFdName = (fdName, optionName, optionArray) => {const parseFdName = (fdName, optionName, stdioLength) => { if (fdName === 'ipc') { return [optionArray.length - 1]; return [stdioLength]; }
const fdNumber = parseFd(fdName); if (fdNumber === undefined || fdNumber === 0) { throw new TypeError(`"${optionName}.${fdName}" is invalid.It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", "${optionName}.ipc", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`); }
if (fdNumber >= optionArray.length) { if (fdNumber !== 'all' && fdNumber >= stdioLength) { throw new TypeError(`"${optionName}.${fdName}" is invalid: that file descriptor does not exist.Please set the "stdio" option to ensure that file descriptor exists.`); }
43 unmodified linesmodified:test/helpers/verbose.js+9 added-2 removed
1 unmodified line2 import {stripVTControlCharacters} from 'node:util';3 import {replaceSymbols} from 'figures';4 import {foobarString} from './input.js';5 import {nestedSubprocess} from './nested.js';6+import {fullStdio} from './stdio.js';7 8 const isWindows = platform === 'win32';9 export const QUOTE = isWindows ? '"' : '\'';10 10-export const runErrorSubprocess = async (t, verbose, isSync = false, expectExitCode = true) => {11- const {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose, isSync});11+export const runErrorSubprocess = async (t, verbose, isSync = false, options = {}) => {12+ const {expectExitCode = true, ...subprocessOptions} = options;13+ const {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose, isSync, ...subprocessOptions});14 t.true(nestedResult instanceof Error);15 if (expectExitCode) {16 t.true(stderr.includes('exit code 2'));17 }27 unmodified lines45 output = '. .',46 ...options47 }) => nestedSubprocess('noop-verbose.js', [output], {48 ipc: !isSync,49+ ...getStdioForFd3Option(fdNumber, secondFdNumber),50 optionsFixture,51 optionsInput: {52 type,53 eventProperty,5 unmodified lines59 isSync,60 ...options,61 });62 63+export const getStdioForFd3Option = (...values) => values.some(value => hasFd3Option(value)) ? fullStdio : {};64+65+const hasFd3Option = value => value === 'fd3' || (typeof value === 'object' && value !== null && Object.hasOwn(value, 'fd3'));66+67 export const getCommandLine = stderr => getCommandLines(stderr)[0];68 export const getCommandLines = stderr => getNormalizedLines(stderr).filter(line => isCommandLine(line));69 const isCommandLine = line => line.includes(' $ ') || line.includes(' | ');70 export const getOutputLine = stderr => getOutputLines(stderr)[0];34 unmodified linesmodified:test/io/max-buffer.js+20 added
127 unmodified lines128 const {isMaxBuffer} = await getMaxBufferSubprocess(execa, 2, {maxBuffer: {stdout: 1}});129 t.false(isMaxBuffer);130 });131 132+test('maxBuffer.fd3 is invalid without stdio[3], even with ipc', t => {133+ const {message} = t.throws(() => {134+ execa('ipc-send-twice.js', {ipc: true, maxBuffer: {fd3: 1}});135+ });136+ t.true(message.includes('"maxBuffer.fd3" is invalid: that file descriptor does not exist.'));137+});138+139+test('maxBuffer.fd3 and maxBuffer.ipc are distinct', async t => {140+ const {isMaxBuffer, ipcOutput} = await execa('ipc-send-twice.js', {141+ ipc: true,142+ stdio: ['ignore', 'pipe', 'pipe', 'pipe'],143+ maxBuffer: {144+ fd3: 1,145+ ipc: 2,146+ },147+ });148+ t.false(isMaxBuffer);149+ t.deepEqual(ipcOutput, foobarArray);150+});151+152 test('maxBuffer.stdout is used for other file descriptors with fd-specific options, sync', async t => {153 const length = 1;154 const {shortMessage, stderr} = await runMaxBuffer(t, execaSync, 2, {maxBuffer: {stdout: length}});155 assertErrorMessage(t, shortMessage, {execaMethod: execaSync, fdNumber: 2, length});153 unmodified linesmodified:test/ipc/buffer-messages.js+13 added
1234567891011 unmodified lines222324252627282930313233343536373839404147 unmodified linesimport test from 'ava';import {execa, execaSync} from '../../index.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';import {foobarString, foobarArray} from '../helpers/input.js';import {PARALLEL_COUNT} from '../helpers/parallel.js';import {fullStdio} from '../helpers/stdio.js';
setFixtureDirectory();
const testResultIpc = async (t, options) => {11 unmodified lines
test('Sets empty result.ipcOutput if buffer is false', testResultNoBuffer, {buffer: false});test('Sets empty result.ipcOutput if buffer is false, fd-specific buffer', testResultNoBuffer, {buffer: {ipc: false}});
test('buffer.fd3 is invalid without stdio[3], even with ipc', t => { const {message} = t.throws(() => { execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}}); }); t.true(message.includes('"buffer.fd3" is invalid: that file descriptor does not exist.'));});
test('buffer.fd3 does not affect result.ipcOutput', async t => { const {ipcOutput} = await execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}, ...fullStdio}); t.deepEqual(ipcOutput, foobarArray);});
test('Can use IPC methods when buffer is false', async t => { const subprocess = execa('ipc-send.js', {ipc: true, buffer: false}); t.is(await subprocess.getOneMessage(), foobarString); const {ipcOutput} = await subprocess;47 unmodified linesmodified:test/verbose/complete.js+7 added-6 removed
9 unmodified lines10 getCompletionLine,11 getCompletionLines,12 testTimestamp,13 getVerboseOption,14+ getStdioForFd3Option,15 stdoutNoneOption,16 stdoutShortOption,17 stdoutFullOption,18 stderrNoneOption,9 unmodified lines28 29 setFixtureDirectory();30 31 const testPrintCompletion = async (t, verbose, isSync) => {31- const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});32+ const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, ...getStdioForFd3Option(verbose), isSync});33 t.is(getCompletionLine(stderr), `${testTimestamp} [0] √ (done in 0ms)`);34 };35 36 test('Prints completion, verbose "short"', testPrintCompletion, 'short', false);17 unmodified lines54 test('Prints completion, verbose "short", fd-specific ipc, sync', testPrintCompletion, ipcShortOption, true);55 test('Prints completion, verbose "full", fd-specific ipc, sync', testPrintCompletion, ipcFullOption, true);56 57 const testNoPrintCompletion = async (t, verbose, isSync) => {57- const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});58+ const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, ...getStdioForFd3Option(verbose), isSync});59 t.is(stderr, '');60 };61 62 test('Does not print completion, verbose "none"', testNoPrintCompletion, 'none', false);62-test('Does not print completion, verbose default"', testNoPrintCompletion, undefined, false);63+test('Does not print completion, verbose default', testNoPrintCompletion, undefined, false);64 test('Does not print completion, verbose "none", fd-specific stdout', testNoPrintCompletion, stdoutNoneOption, false);65 test('Does not print completion, verbose "none", fd-specific stderr', testNoPrintCompletion, stderrNoneOption, false);66 test('Does not print completion, verbose "none", fd-specific fd3', testNoPrintCompletion, fd3NoneOption, false);67 test('Does not print completion, verbose "none", fd-specific ipc', testNoPrintCompletion, ipcNoneOption, false);67-test('Does not print completion, verbose default", fd-specific', testNoPrintCompletion, {}, false);68+test('Does not print completion, verbose default, fd-specific', testNoPrintCompletion, {}, false);69 test('Does not print completion, verbose "none", sync', testNoPrintCompletion, 'none', true);69-test('Does not print completion, verbose default", sync', testNoPrintCompletion, undefined, true);70+test('Does not print completion, verbose default, sync', testNoPrintCompletion, undefined, true);71 test('Does not print completion, verbose "none", fd-specific stdout, sync', testNoPrintCompletion, stdoutNoneOption, true);72 test('Does not print completion, verbose "none", fd-specific stderr, sync', testNoPrintCompletion, stderrNoneOption, true);73 test('Does not print completion, verbose "none", fd-specific fd3, sync', testNoPrintCompletion, fd3NoneOption, true);74 test('Does not print completion, verbose "none", fd-specific ipc, sync', testNoPrintCompletion, ipcNoneOption, true);74-test('Does not print completion, verbose default", fd-specific, sync', testNoPrintCompletion, {}, true);75+test('Does not print completion, verbose default, fd-specific, sync', testNoPrintCompletion, {}, true);76 77 const testPrintCompletionError = async (t, isSync) => {78 const stderr = await runErrorSubprocess(t, 'short', isSync);79 t.is(getCompletionLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);51 unmodified linesmodified:test/verbose/error.js+7 added-4 removed
1 import test from 'ava';2 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';3-import {foobarString, foobarRed} from '../helpers/input.js';3+import {foobarString} from '../helpers/input.js';4 import {nestedSubprocess} from '../helpers/nested.js';5 import {6 QUOTE,7 runErrorSubprocess,1 unmodified line9 getErrorLine,10 getErrorLines,11 testTimestamp,12 getVerboseOption,13+ getStdioForFd3Option,14 stdoutNoneOption,15 stdoutShortOption,16 stdoutFullOption,17 stderrNoneOption,8 unmodified lines26 } from '../helpers/verbose.js';27 28 setFixtureDirectory();29 30+const redFoobarString = `\u001B[31m${foobarString}\u001B[39m`;31+32 const testPrintError = async (t, verbose, isSync) => {30- const stderr = await runErrorSubprocess(t, verbose, isSync);33+ const stderr = await runErrorSubprocess(t, verbose, isSync, getStdioForFd3Option(verbose));34 t.is(getErrorLine(stderr), `${testTimestamp} [0] × Command failed with exit code 2: noop-fail.js 1 ${foobarString}`);35 };36 37 test('Prints error, verbose "short"', testPrintError, 'short', false);17 unmodified lines55 test('Prints error, verbose "short", fd-specific ipc, sync', testPrintError, ipcShortOption, true);56 test('Prints error, verbose "full", fd-specific ipc, sync', testPrintError, ipcFullOption, true);57 58 const testNoPrintError = async (t, verbose, isSync) => {56- const stderr = await runErrorSubprocess(t, verbose, isSync, false);59+ const stderr = await runErrorSubprocess(t, verbose, isSync, {expectExitCode: false, ...getStdioForFd3Option(verbose)});60 t.is(getErrorLine(stderr), undefined);61 };62 63 test('Does not print error, verbose "none"', testNoPrintError, 'none', false);87 unmodified lines151 ]);152 });153 154 test('Escapes and strips color sequences from error', async t => {152- const {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', [foobarRed], {parentFixture: 'nested-fail.js', verbose: 'short'}));155+ const {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', [redFoobarString], {parentFixture: 'nested-fail.js', verbose: 'short'}));156 t.deepEqual(getErrorLines(stderr), [157 `${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}\\u001b[31m${foobarString}\\u001b[39m${QUOTE}`,158 `${testTimestamp} [0] × ${foobarString}`,159 ]);9 unmodified linesmodified:test/verbose/ipc.js+18 added-2 removed
1 import {on} from 'node:events';2 import {inspect} from 'node:util';3 import test from 'ava';4+import {red} from 'yoctocolors';5+import {execa} from '../../index.js';6 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5-import {foobarString, foobarRed, foobarObject} from '../helpers/input.js';7+import {foobarString, foobarObject} from '../helpers/input.js';8 import {nestedSubprocess, nestedInstance} from '../helpers/nested.js';9+import {fullStdio} from '../helpers/stdio.js';10 import {11 getIpcLine,12 getIpcLines,13 testTimestamp,11 unmodified lines25 26 test('Prints IPC, verbose "full"', testPrintIpc, 'full');27 test('Prints IPC, verbose "full", fd-specific', testPrintIpc, ipcFullOption);28 29+test('verbose.fd3 is invalid without stdio[3], even with ipc', t => {30+ const {message} = t.throws(() => {31+ execa('ipc-send.js', {ipc: true, verbose: {fd3: 'full'}});32+ });33+ t.true(message.includes('"verbose.fd3" is invalid: that file descriptor does not exist.'));34+});35+36+test('verbose.fd3 does not affect IPC', async t => {37+ const {nestedResult, stderr} = await nestedSubprocess('ipc-send.js', {ipc: true, verbose: {fd3: 'full'}, ...fullStdio});38+ t.deepEqual(nestedResult.ipcOutput, [foobarString]);39+ t.is(getIpcLine(stderr), undefined);40+});41+42 const testNoPrintIpc = async (t, verbose) => {43 const {stderr} = await nestedSubprocess('ipc-send.js', {ipc: true, verbose});44 t.is(getIpcLine(stderr), undefined);45 };52 unmodified lines98 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ã`);99 });100 101 test('Strips color sequences from IPC', async t => {86- const {stderr} = await nestedSubprocess('ipc-send.js', [foobarRed], {ipc: true, verbose: 'full'});102+ const {stderr} = await nestedSubprocess('ipc-send.js', [red(foobarString)], {ipc: true, verbose: 'full'}, {env: {FORCE_COLOR: '1', NO_COLOR: undefined}});103 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);104 });105 106 test('Escapes control characters from IPC', async t => {17 unmodified linesmodified:test/verbose/output-enable.js+3 added-2 removed
1 import test from 'ava';2+import {red} from 'yoctocolors';3 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';3-import {foobarString, foobarRed, foobarUtf16Uint8Array} from '../helpers/input.js';4+import {foobarString, foobarUtf16Uint8Array} from '../helpers/input.js';5 import {fullStdio} from '../helpers/stdio.js';6 import {nestedSubprocess} from '../helpers/nested.js';7 import {8 runErrorSubprocess,96 unmodified lines105 t.is(getOutputLine(stderr), `${testTimestamp} [0] ã`);106 });107 108 test('Strips color sequences from stdout', async t => {108- const {stderr} = await nestedSubprocess('noop.js', [foobarRed], {verbose: 'full'});109+ const {stderr} = await nestedSubprocess('noop.js', [red(foobarString)], {verbose: 'full'}, {env: {FORCE_COLOR: '1', NO_COLOR: undefined}});110 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);111 });112 113 test('Escapes control characters from stdout', async t => {32 unmodified linesmodified:test/verbose/start.js+12 added-4 removed
1 import test from 'ava';2 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';3-import {foobarString, foobarRed} from '../helpers/input.js';3+import {foobarString} from '../helpers/input.js';4 import {nestedSubprocess} from '../helpers/nested.js';5 import {6 QUOTE,7 runErrorSubprocess,1 unmodified line9 getCommandLine,10 getCommandLines,11 testTimestamp,12 getVerboseOption,13+ getStdioForFd3Option,14 stdoutNoneOption,15 stdoutShortOption,16 stdoutFullOption,17 stderrNoneOption,8 unmodified lines26 } from '../helpers/verbose.js';27 28 setFixtureDirectory();29 30+const redFoobarString = `\u001B[31m${foobarString}\u001B[39m`;31+32 const testPrintCommand = async (t, verbose, worker, isSync) => {30- const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, worker, isSync});33+ const {stderr} = await nestedSubprocess('noop.js', [foobarString], {34+ verbose,35+ ...getStdioForFd3Option(verbose),36+ worker,37+ isSync,38+ });39 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);40 };41 42 test('Prints command, verbose "short"', testPrintCommand, 'short', false, false);37 unmodified lines80 test('Prints command, verbose "short", fd-specific ipc, worker, sync', testPrintCommand, ipcShortOption, true, true);81 test('Prints command, verbose "full", fd-specific ipc, worker, sync', testPrintCommand, ipcFullOption, true, true);82 83 const testNoPrintCommand = async (t, verbose, isSync) => {76- const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});84+ const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, ...getStdioForFd3Option(verbose), isSync});85 t.is(stderr, '');86 };87 88 test('Does not print command, verbose "none"', testNoPrintCommand, 'none', false);69 unmodified lines158 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}ã${QUOTE}`);159 });160 161 test('Escapes color sequences from command', async t => {154- const {stderr} = await nestedSubprocess('noop.js', [foobarRed], {verbose: 'short'});162+ const {stderr} = await nestedSubprocess('noop.js', [redFoobarString], {verbose: 'short'});163 t.true(getCommandLine(stderr).includes(`${QUOTE}\\u001b[31m${foobarString}\\u001b[39m${QUOTE}`));164 });165 166 test('Escapes control characters from command', async t => {3 unmodified linesmodified:test-d/arguments/specific.test-d.ts+10 added-10 removed
7 unmodified lines8 await execa('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});9 await execa('unicorns', {maxBuffer: {all: 0}});10 await execa('unicorns', {maxBuffer: {fd1: 0}});11 await execa('unicorns', {maxBuffer: {fd2: 0}});12-await execa('unicorns', {maxBuffer: {fd3: 0}});12+await execa('unicorns', {maxBuffer: {fd3: 0}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});13 await execa('unicorns', {maxBuffer: {ipc: 0}});14 expectError(await execa('unicorns', {maxBuffer: {stdout: '0'}}));15 16 execaSync('unicorns', {maxBuffer: {}});3 unmodified lines20 execaSync('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});21 execaSync('unicorns', {maxBuffer: {all: 0}});22 execaSync('unicorns', {maxBuffer: {fd1: 0}});23 execaSync('unicorns', {maxBuffer: {fd2: 0}});24-execaSync('unicorns', {maxBuffer: {fd3: 0}});24+execaSync('unicorns', {maxBuffer: {fd3: 0}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});25 execaSync('unicorns', {maxBuffer: {ipc: 0}});26 expectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));27 28 await execa('unicorns', {verbose: {}});3 unmodified lines32 await execa('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});33 await execa('unicorns', {verbose: {all: 'none'}});34 await execa('unicorns', {verbose: {fd1: 'none'}});35 await execa('unicorns', {verbose: {fd2: 'none'}});36-await execa('unicorns', {verbose: {fd3: 'none'}});36+await execa('unicorns', {verbose: {fd3: 'none'}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});37 await execa('unicorns', {verbose: {ipc: 'none'}});38 expectError(await execa('unicorns', {verbose: {stdout: 'other'}}));39 40 execaSync('unicorns', {verbose: {}});3 unmodified lines44 execaSync('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});45 execaSync('unicorns', {verbose: {all: 'none'}});46 execaSync('unicorns', {verbose: {fd1: 'none'}});47 execaSync('unicorns', {verbose: {fd2: 'none'}});48-execaSync('unicorns', {verbose: {fd3: 'none'}});48+execaSync('unicorns', {verbose: {fd3: 'none'}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});49 execaSync('unicorns', {verbose: {ipc: 'none'}});50 expectError(execaSync('unicorns', {verbose: {stdout: 'other'}}));51 52 await execa('unicorns', {stripFinalNewline: {}});3 unmodified lines56 await execa('unicorns', {stripFinalNewline: {stdout: true, stderr: true} as const});57 await execa('unicorns', {stripFinalNewline: {all: true}});58 await execa('unicorns', {stripFinalNewline: {fd1: true}});59 await execa('unicorns', {stripFinalNewline: {fd2: true}});60-await execa('unicorns', {stripFinalNewline: {fd3: true}});60+await execa('unicorns', {stripFinalNewline: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});61 await execa('unicorns', {stripFinalNewline: {ipc: true}});62 expectError(await execa('unicorns', {stripFinalNewline: {stdout: 'true'}}));63 64 execaSync('unicorns', {stripFinalNewline: {}});3 unmodified lines68 execaSync('unicorns', {stripFinalNewline: {stdout: true, stderr: true} as const});69 execaSync('unicorns', {stripFinalNewline: {all: true}});70 execaSync('unicorns', {stripFinalNewline: {fd1: true}});71 execaSync('unicorns', {stripFinalNewline: {fd2: true}});72-execaSync('unicorns', {stripFinalNewline: {fd3: true}});72+execaSync('unicorns', {stripFinalNewline: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});73 execaSync('unicorns', {stripFinalNewline: {ipc: true}});74 expectError(execaSync('unicorns', {stripFinalNewline: {stdout: 'true'}}));75 76 await execa('unicorns', {lines: {}});3 unmodified lines80 await execa('unicorns', {lines: {stdout: true, stderr: true} as const});81 await execa('unicorns', {lines: {all: true}});82 await execa('unicorns', {lines: {fd1: true}});83 await execa('unicorns', {lines: {fd2: true}});84-await execa('unicorns', {lines: {fd3: true}});84+await execa('unicorns', {lines: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});85 await execa('unicorns', {lines: {ipc: true}});86 expectError(await execa('unicorns', {lines: {stdout: 'true'}}));87 88 execaSync('unicorns', {lines: {}});3 unmodified lines92 execaSync('unicorns', {lines: {stdout: true, stderr: true} as const});93 execaSync('unicorns', {lines: {all: true}});94 execaSync('unicorns', {lines: {fd1: true}});95 execaSync('unicorns', {lines: {fd2: true}});96-execaSync('unicorns', {lines: {fd3: true}});96+execaSync('unicorns', {lines: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});97 execaSync('unicorns', {lines: {ipc: true}});98 expectError(execaSync('unicorns', {lines: {stdout: 'true'}}));99 100 await execa('unicorns', {buffer: {}});3 unmodified lines104 await execa('unicorns', {buffer: {stdout: true, stderr: true} as const});105 await execa('unicorns', {buffer: {all: true}});106 await execa('unicorns', {buffer: {fd1: true}});107 await execa('unicorns', {buffer: {fd2: true}});108-await execa('unicorns', {buffer: {fd3: true}});108+await execa('unicorns', {buffer: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});109 await execa('unicorns', {buffer: {ipc: true}});110 expectError(await execa('unicorns', {buffer: {stdout: 'true'}}));111 112 execaSync('unicorns', {buffer: {}});3 unmodified lines116 execaSync('unicorns', {buffer: {stdout: true, stderr: true} as const});117 execaSync('unicorns', {buffer: {all: true}});118 execaSync('unicorns', {buffer: {fd1: true}});119 execaSync('unicorns', {buffer: {fd2: true}});120-execaSync('unicorns', {buffer: {fd3: true}});120+execaSync('unicorns', {buffer: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});121 execaSync('unicorns', {buffer: {ipc: true}});122 expectError(execaSync('unicorns', {buffer: {stdout: 'true'}}));123 124 expectError(await execa('unicorns', {preferLocal: {}}));35 unmodified linesmodified:test-d/return/no-buffer-specific.test-d.ts+7 added
43 unmodified lines44 expectType<string>(noBufferFd3Result.all);45 expectType<undefined>(noBufferFd3Result.stdio[3]);46 expectType<string>(noBufferFd3Result.stdio[4]);47 48+const noBufferIpcResult = await execa('unicorns', {buffer: {ipc: false}, ipc: true, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});49+expectType<string>(noBufferIpcResult.stdio[3]);50+expectType<[]>(noBufferIpcResult.ipcOutput);51+52 const noBufferStdoutResultSync = execaSync('unicorns', {all: true, buffer: {stdout: false}});53 expectType<undefined>(noBufferStdoutResultSync.stdout);54 expectType<undefined>(noBufferStdoutResultSync.stdio[1]);55 expectType<string>(noBufferStdoutResultSync.stderr);35 unmodified lines91 expectType<string>(noBufferFd3ResultSync.stdio[2]);92 expectType<string>(noBufferFd3ResultSync.all);93 expectType<undefined>(noBufferFd3ResultSync.stdio[3]);94 expectType<string>(noBufferFd3ResultSync.stdio[4]);95+96+const noBufferIpcStdioResultSync = execaSync('unicorns', {buffer: {ipc: false}, stdio: ['pipe', 'pipe', 'pipe', 'pipe']});97+expectType<string>(noBufferIpcStdioResultSync.stdio[3]);modified:types/arguments/specific.d.ts+19 added-17 removed
27 unmodified lines28 29 type FdNumberToFromOption<30 FdNumber extends string,31 GenericOptionKeys extends GenericFromOption,32-> = FdNumber extends '1'33- ? 'stdout' extends GenericOptionKeys34- ? 'stdout'35- : 'fd1' extends GenericOptionKeys36- ? 'fd1'37- : 'all' extends GenericOptionKeys38- ? 'all'39- : never40- : FdNumber extends '2'41- ? 'stderr' extends GenericOptionKeys42- ? 'stderr'43- : 'fd2' extends GenericOptionKeys44- ? 'fd2'32+> = FdNumber extends 'ipc'33+ ? 'ipc' extends GenericOptionKeys34+ ? 'ipc'35+ : never36+ : FdNumber extends '1'37+ ? 'stdout' extends GenericOptionKeys38+ ? 'stdout'39+ : 'fd1' extends GenericOptionKeys40+ ? 'fd1'41 : 'all' extends GenericOptionKeys42 ? 'all'43 : never44+ : FdNumber extends '2'45+ ? 'stderr' extends GenericOptionKeys46+ ? 'stderr'48- : `fd${FdNumber}` extends GenericOptionKeys49- ? `fd${FdNumber}`50- : 'ipc' extends GenericOptionKeys51- ? 'ipc'47+ : 'fd2' extends GenericOptionKeys48+ ? 'fd2'49+ : 'all' extends GenericOptionKeys50+ ? 'all'51+ : never52+ : `fd${FdNumber}` extends GenericOptionKeys53+ ? `fd${FdNumber}`54 : never;55 56 export {};