Skip to content
Myr

Remove the old `stdio: [..., 'ipc']` syntax (#1245)

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 3ced394 · Browse files · 14 files+43 added−88 removed
This commit

State

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

Diff stats

14 files+43 added−88 removed

  • tests:+22 added−52 removed
  • other:+21 added−36 removed

14 files+43 added−88 removed

modified:lib/ipc/array.js+1 added-1 removed
modified:lib/stdio/handle-sync.js+1 added-1 removed
modified:lib/stdio/handle.js+2 added-2 removed
102 unmodified lines
103 }104 }105};106107// Using those `stdio` values together with others for the same stream does not make sense, so we make it fail.107// Using the `ignore` value together with others for the same stream does not make sense, so we make it fail.108// However, we do allow it if the array has a single item.109const INVALID_STDIO_ARRAY_OPTIONS = new Set(['ignore', 'ipc']);109const INVALID_STDIO_ARRAY_OPTIONS = new Set(['ignore']);110111const validateStreams = stdioItems => {112 for (const stdioItem of stdioItems) {113 validateFileStdio(stdioItem);
110 unmodified lines
modified:lib/stdio/stdio-option.js+8 added
modified:test/arguments/fd-options.js-21 removed
617 unmodified lines
618 sourceOptions: {stdin: 'inherit'},619 message: ['stdin', '\'inherit\''],620 writable: true,621});622test('Cannot set "stdout" option to "ipc" to use .pipe()', testPipeError, {623 sourceOptions: {stdout: 'ipc'},624 message: ['stdout', '\'ipc\''],625});626test('Cannot set "stdout" option to "ipc" to use .duplex()', testNodeStream, {627 sourceOptions: {stdout: 'ipc'},628 message: ['stdout', '\'ipc\''],629});630test('Cannot set "stdout" option to "ipc" to use .iterable()', testIterable, {631 sourceOptions: {stdout: 'ipc'},632 message: ['stdout', '\'ipc\''],633});634test('Cannot set "stdin" option to "ipc" to use .pipe()', testPipeError, {635 destinationOptions: {stdin: 'ipc'},636 message: ['stdin', '\'ipc\''],637});638test('Cannot set "stdin" option to "ipc" to use .duplex()', testNodeStream, {639 sourceOptions: {stdin: 'ipc'},640 message: ['stdin', '\'ipc\''],641 writable: true,642});622test('Cannot set "stdout" option to file descriptors to use .pipe()', testPipeError, {623 sourceOptions: {stdout: 1},624 message: ['stdout', '1'],625});
93 unmodified lines
modified:test/ipc/validation.js-6 removed
1import test from 'ava';2import {execa} from '../../index.js';3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString} from '../helpers/input.js';5import {getStdio} from '../helpers/stdio.js';56setFixtureDirectory();79const stdioIpc = getStdio(3, 'ipc');108const testRequiredIpcSubprocess = async (t, methodName, options) => {9 const subprocess = execa('empty.js', options);10 const {message} = await t.throws(() => subprocess[methodName]());11 t.true(message.includes(`subprocess.${methodName}() can only be used`));
1 unmodified line
13};1415test('Cannot use subprocess.sendMessage() without ipc option', testRequiredIpcSubprocess, 'sendMessage', {});16test('Cannot use subprocess.sendMessage() with ipc: false', testRequiredIpcSubprocess, 'sendMessage', {ipc: false});20test('Cannot use subprocess.sendMessage() with stdio: [..., "ipc"]', testRequiredIpcSubprocess, 'sendMessage', stdioIpc);17test('Cannot use subprocess.getOneMessage() without ipc option', testRequiredIpcSubprocess, 'getOneMessage', {});18test('Cannot use subprocess.getOneMessage() with ipc: false', testRequiredIpcSubprocess, 'getOneMessage', {ipc: false});23test('Cannot use subprocess.getOneMessage() with stdio: [..., "ipc"]', testRequiredIpcSubprocess, 'getOneMessage', stdioIpc);19test('Cannot use subprocess.getEachMessage() without ipc option', testRequiredIpcSubprocess, 'getEachMessage', {});20test('Cannot use subprocess.getEachMessage() with ipc: false', testRequiredIpcSubprocess, 'getEachMessage', {ipc: false});26test('Cannot use subprocess.getEachMessage() with stdio: [..., "ipc"]', testRequiredIpcSubprocess, 'getEachMessage', stdioIpc);2122const testRequiredIpcExports = async (t, methodName, options) => {23 const {message} = await t.throwsAsync(execa('ipc-any.js', [methodName], options));24 t.true(message.includes(`${methodName}() can only be used`));
70 unmodified lines
modified:test/methods/node.js-1 removed
250 unmodified lines
251test('The "node" option adds an ipc channel', testIpc, runWithNodeOption, {});252test('The "ipc" option adds an ipc channel', testIpc, runWithIpc, {});253test('The "ipc" option works with "stdio: \'pipe\'"', testIpc, runWithIpc, {stdio: 'pipe'});254test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe']});255test('The "ipc" option works with "stdio: [\'pipe\', \'pipe\', \'pipe\', \'ipc\']"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});255test('The "ipc" option works with "stdout: \'pipe\'"', testIpc, runWithIpc, {stdout: 'pipe'});256257const NO_SEND_MESSAGE = 'sendMessage() can only be used';258
43 unmodified lines
modified:test/stdio/handle-invalid.js+22 added-12 removed
modified:test/stdio/handle-options.js-8 removed
12 unmodified lines
1314test('stdin can be "ignore"', testNoPipeOption, 'ignore', 0);15test('stdin can be ["ignore"]', testNoPipeOption, ['ignore'], 0);16test('stdin can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 0);17test('stdin can be "ipc"', testNoPipeOption, 'ipc', 0);18test('stdin can be ["ipc"]', testNoPipeOption, ['ipc'], 0);17test('stdin can be "inherit"', testNoPipeOption, 'inherit', 0);18test('stdin can be ["inherit"]', testNoPipeOption, ['inherit'], 0);19test('stdin can be 0', testNoPipeOption, 0, 0);20test('stdin can be [0]', testNoPipeOption, [0], 0);21test('stdout can be "ignore"', testNoPipeOption, 'ignore', 1);22test('stdout can be ["ignore"]', testNoPipeOption, ['ignore'], 1);23test('stdout can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 1);26test('stdout can be "ipc"', testNoPipeOption, 'ipc', 1);27test('stdout can be ["ipc"]', testNoPipeOption, ['ipc'], 1);24test('stdout can be "inherit"', testNoPipeOption, 'inherit', 1);25test('stdout can be ["inherit"]', testNoPipeOption, ['inherit'], 1);26test('stdout can be 1', testNoPipeOption, 1, 1);27test('stdout can be [1]', testNoPipeOption, [1], 1);28test('stderr can be "ignore"', testNoPipeOption, 'ignore', 2);29test('stderr can be ["ignore"]', testNoPipeOption, ['ignore'], 2);30test('stderr can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 2);35test('stderr can be "ipc"', testNoPipeOption, 'ipc', 2);36test('stderr can be ["ipc"]', testNoPipeOption, ['ipc'], 2);31test('stderr can be "inherit"', testNoPipeOption, 'inherit', 2);32test('stderr can be ["inherit"]', testNoPipeOption, ['inherit'], 2);33test('stderr can be 2', testNoPipeOption, 2, 2);34test('stderr can be [2]', testNoPipeOption, [2], 2);35test('stdio[*] can be "ignore"', testNoPipeOption, 'ignore', 3);36test('stdio[*] can be ["ignore"]', testNoPipeOption, ['ignore'], 3);37test('stdio[*] can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 3);44test('stdio[*] can be "ipc"', testNoPipeOption, 'ipc', 3);45test('stdio[*] can be ["ipc"]', testNoPipeOption, ['ipc'], 3);38test('stdio[*] can be "inherit"', testNoPipeOption, 'inherit', 3);39test('stdio[*] can be ["inherit"]', testNoPipeOption, ['inherit'], 3);40test('stdio[*] can be 3', testNoPipeOption, 3, 3);41test('stdio[*] can be [3]', testNoPipeOption, [3], 3);
modified:test/transform/encoding-ignored.js-4 removed
28 unmodified lines
29const base64Options = {encoding: 'base64'};30const linesOptions = {lines: true};31test('Is ignored with other encodings and "ignore"', testIgnoredEncoding, 'ignore', true, base64Options, execa);32test('Is ignored with other encodings and ["ignore"]', testIgnoredEncoding, ['ignore'], true, base64Options, execa);33test('Is ignored with other encodings and "ipc"', testIgnoredEncoding, 'ipc', true, base64Options, execa);34test('Is ignored with other encodings and ["ipc"]', testIgnoredEncoding, ['ipc'], true, base64Options, execa);33test('Is ignored with other encodings and "inherit"', testIgnoredEncoding, 'inherit', true, base64Options, execa);34test('Is ignored with other encodings and ["inherit"]', testIgnoredEncoding, ['inherit'], true, base64Options, execa);35test('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true, base64Options, execa);36test('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true, base64Options, execa);
7 unmodified lines
44test('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false, base64Options, execa);45test('Is not ignored with other encodings and null', testIgnoredEncoding, null, false, base64Options, execa);46test('Is ignored with "lines: true" and "ignore"', testIgnoredEncoding, 'ignore', true, linesOptions, execa);47test('Is ignored with "lines: true" and ["ignore"]', testIgnoredEncoding, ['ignore'], true, linesOptions, execa);50test('Is ignored with "lines: true" and "ipc"', testIgnoredEncoding, 'ipc', true, linesOptions, execa);51test('Is ignored with "lines: true" and ["ipc"]', testIgnoredEncoding, ['ipc'], true, linesOptions, execa);48test('Is ignored with "lines: true" and "inherit"', testIgnoredEncoding, 'inherit', true, linesOptions, execa);49test('Is ignored with "lines: true" and ["inherit"]', testIgnoredEncoding, ['inherit'], true, linesOptions, execa);50test('Is ignored with "lines: true" and 1', testIgnoredEncoding, 1, true, linesOptions, execa);51test('Is ignored with "lines: true" and [1]', testIgnoredEncoding, [1], true, linesOptions, execa);
37 unmodified lines
modified:test-d/return/ignore-other.test-d.ts-20 removed
55 unmodified lines
56expectType<string>(inheritStderrErrorSync.stdout);57expectType<undefined>(inheritStderrErrorSync.stderr);58expectType<string>(inheritStderrErrorSync.all);5960const ipcStdoutResult = await execa('unicorns', {stdout: 'ipc', all: true});61expectType<undefined>(ipcStdoutResult.stdout);62expectType<string>(ipcStdoutResult.stderr);63expectType<string>(ipcStdoutResult.all);6465const ipcStderrResult = await execa('unicorns', {stderr: 'ipc', all: true});66expectType<string>(ipcStderrResult.stdout);67expectType<undefined>(ipcStderrResult.stderr);68expectType<string>(ipcStderrResult.all);6970const ipcStdoutError = new Error('.') as ExecaError<{stdout: 'ipc'; all: true}>;71expectType<undefined>(ipcStdoutError.stdout);72expectType<string>(ipcStdoutError.stderr);73expectType<string>(ipcStdoutError.all);7475const ipcStderrError = new Error('.') as ExecaError<{stderr: 'ipc'; all: true}>;76expectType<string>(ipcStderrError.stdout);77expectType<undefined>(ipcStderrError.stderr);78expectType<string>(ipcStderrError.all);7960const streamStdoutResult = await execa('unicorns', {stdout: process.stdout, all: true});61expectType<undefined>(streamStdoutResult.stdout);62expectType<string>(streamStdoutResult.stderr);63expectType<string>(streamStdoutResult.all);
75 unmodified lines
modified:test-d/stdio/option/ipc.test-d.ts+8 added-7 removed
1import {expectError, expectAssignable, expectNotAssignable} from 'tsd';1import {expectError, expectNotAssignable} from 'tsd';2import {3 execa,4 execaSync,5 type StdinOption,
1 unmodified line
7 type StdoutStderrOption,8 type StdoutStderrSyncOption,9} from '../../../index.js';1011await execa('unicorns', {stdin: 'ipc'});11// The `stdio: 'ipc'` value (raw `child_process` syntax) was replaced by the `ipc: true` option12expectError(await execa('unicorns', {stdin: 'ipc'}));13expectError(execaSync('unicorns', {stdin: 'ipc'}));14expectError(await execa('unicorns', {stdin: ['ipc']}));15expectError(execaSync('unicorns', {stdin: ['ipc']}));1616await execa('unicorns', {stdout: 'ipc'});17expectError(await execa('unicorns', {stdout: 'ipc'}));18expectError(execaSync('unicorns', {stdout: 'ipc'}));19expectError(await execa('unicorns', {stdout: ['ipc']}));20expectError(execaSync('unicorns', {stdout: ['ipc']}));2121await execa('unicorns', {stderr: 'ipc'});22expectError(await execa('unicorns', {stderr: 'ipc'}));23expectError(execaSync('unicorns', {stderr: 'ipc'}));24expectError(await execa('unicorns', {stderr: ['ipc']}));25expectError(execaSync('unicorns', {stderr: ['ipc']}));2627expectError(await execa('unicorns', {stdio: 'ipc'}));28expectError(execaSync('unicorns', {stdio: 'ipc'}));2929await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});30expectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}));31expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}));32expectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ipc']]}));33expectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ipc']]}));3434expectAssignable<StdinOption>('ipc');35expectNotAssignable<StdinOption>('ipc');36expectNotAssignable<StdinSyncOption>('ipc');37expectNotAssignable<StdinOption>(['ipc']);38expectNotAssignable<StdinSyncOption>(['ipc']);3939expectAssignable<StdoutStderrOption>('ipc');40expectNotAssignable<StdoutStderrOption>('ipc');41expectNotAssignable<StdoutStderrSyncOption>('ipc');42expectNotAssignable<StdoutStderrOption>(['ipc']);43expectNotAssignable<StdoutStderrSyncOption>(['ipc']);
modified:types/stdio/type.d.ts+1 added-3 removed
1 unmodified line
2import type {ReadableStream, WritableStream, TransformStream} from 'node:stream/web';3import type {4 Not,5 And,6 Or,6 Unless,7 AndUnless,8} from '../utils.js';9import type {
10 unmodified lines
20// When `options.stdin|stdout|stderr|stdio` is set to one of those values, no stream is created21export type NoStreamStdioOption<FdNumber extends string> =22 | 'ignore'23 | 'inherit'25 | 'ipc'24 | number25 | Readable26 | Writable27 | Unless<IsStandardStream<FdNumber>, undefined>
16 unmodified lines
44 IsSync extends boolean,45 IsExtra extends boolean,46 IsArray extends boolean,47> =50 SimpleStdioOption<IsSync, IsExtra, IsArray> | URL | GeneratorTransform<IsSync> | GeneratorTransformFull<IsSync> | Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9> | Unless<Or<IsSync, IsArray>, 'ipc'> | Unless<IsSync, DuplexTransform | WebTransform | TransformStream> | {readonly file: string; readonly append?: boolean};48 SimpleStdioOption<IsSync, IsExtra, IsArray> | URL | GeneratorTransform<IsSync> | GeneratorTransformFull<IsSync> | Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9> | Unless<IsSync, DuplexTransform | WebTransform | TransformStream> | {readonly file: string; readonly append?: boolean};4950// Synchronous iterables excluding strings, Uint8Arrays and Arrays51type IterableObject<IsArray extends boolean> = Iterable<unknown>52 & object
111 unmodified lines
modified:types/utils.d.ts-2 removed
1export type Not<Value extends boolean> = Value extends true ? false : true;23export type And<First extends boolean, Second extends boolean> = First extends true ? Second : false;45export type Or<First extends boolean, Second extends boolean> = First extends true ? true : Second;65export type Unless<Condition extends boolean, ThenValue, ElseValue = never> = Condition extends true ? ElseValue : ThenValue;67export type AndUnless<Condition extends boolean, ThenValue, ElseValue = unknown> = Condition extends true ? ElseValue : ThenValue;8
5 unmodified lines