Skip to content
Myr

Rename `from|to: 3` to `from|to: 'fd3'` (#920)

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

authored by ehmicky · committed by GitHub · parent 26e9150 · Browse files · 11 files+203 added−128 removed
This commit

State

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

Diff stats

11 files+203 added−128 removed

  • tests:+120 added−78 removed
  • other:+83 added−50 removed

11 files+203 added−128 removed

modified:lib/pipe/validate.js+33 added-19 removed
modified:test/convert/concurrent.js+20 added-20 removed
50 unmodified lines
51 ]);52 await assertSubprocessOutput(t, subprocess, foobarString, fdNumber);53};5455test('Can call .readable() twice on same file descriptor', testReadableTwice, 1, undefined);55test('Can call .readable() twice on same file descriptor', testReadableTwice, 1);56test('Can call .readable({from: "stderr"}) twice on same file descriptor', testReadableTwice, 2, 'stderr');5758const testWritableTwice = async (t, fdNumber, options) => {58const testWritableTwice = async (t, fdNumber, to, options) => {59 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);60 const stream = subprocess.writable({to: fdNumber});61 const secondStream = subprocess.writable({to: fdNumber});60 const stream = subprocess.writable({to});61 const secondStream = subprocess.writable({to});6263 await Promise.all([64 finishedStream(stream),65 finishedStream(secondStream),
1 unmodified line
67 ]);68 await assertSubprocessOutput(t, subprocess, `${foobarString}${foobarString}`);69};7071test('Can call .writable() twice on same file descriptor', testWritableTwice, 0, {});72test('Can call .writable({to: 3}) twice on same file descriptor', testWritableTwice, 3, fullReadableStdio());71test('Can call .writable() twice on same file descriptor', testWritableTwice, 0, undefined, {});72test('Can call .writable({to: "fd3"}) twice on same file descriptor', testWritableTwice, 3, 'fd3', fullReadableStdio());7374const testDuplexTwice = async (t, fdNumber, options) => {74const testDuplexTwice = async (t, fdNumber, to, options) => {75 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);76 const stream = subprocess.duplex({to: fdNumber});77 const secondStream = subprocess.duplex({to: fdNumber});76 const stream = subprocess.duplex({to});77 const secondStream = subprocess.duplex({to});7879 const expectedOutput = `${foobarString}${foobarString}`;80 await Promise.all([81 assertStreamOutput(t, stream, expectedOutput),
2 unmodified lines
84 ]);85 await assertSubprocessOutput(t, subprocess, expectedOutput);86};8788test('Can call .duplex() twice on same file descriptor', testDuplexTwice, 0, {});89test('Can call .duplex({to: 3}) twice on same file descriptor', testDuplexTwice, 3, fullReadableStdio());88test('Can call .duplex() twice on same file descriptor', testDuplexTwice, 0, undefined, {});89test('Can call .duplex({to: "fd3"}) twice on same file descriptor', testDuplexTwice, 3, 'fd3', fullReadableStdio());9091test('Can call .duplex() twice on same readable file descriptor but different writable one', async t => {92 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());93 const stream = subprocess.duplex({to: 0});94 const secondStream = subprocess.duplex({to: 3});93 const stream = subprocess.duplex();94 const secondStream = subprocess.duplex({to: 'fd3'});9596 const expectedOutput = `${foobarString}${foobarString}`;97 await Promise.all([98 assertStreamOutput(t, stream, expectedOutput),
19 unmodified lines
118119test('Can call .writable() twice on different file descriptors', async t => {120 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());121 const stream = subprocess.writable();122 const secondStream = subprocess.writable({to: 3});122 const secondStream = subprocess.writable({to: 'fd3'});123124 await Promise.all([125 finishedStream(stream),126 finishedStream(secondStream),
4 unmodified lines
131132test('Can call .duplex() twice on different file descriptors', async t => {133 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());134 const stream = subprocess.duplex();135 const secondStream = subprocess.duplex({from: 'stderr', to: 3});135 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});136137 await Promise.all([138 assertStreamOutput(t, stream),139 assertStreamOutput(t, secondStream),
18 unmodified lines
158159test('Can call .writable() and .duplex()', async t => {160 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());161 const stream = subprocess.duplex();162 const secondStream = subprocess.writable({to: 3});162 const secondStream = subprocess.writable({to: 'fd3'});163164 const expectedOutput = `${foobarString}${foobarString}`;165 await Promise.all([166 assertStreamOutput(t, stream, expectedOutput),
112 unmodified lines
279280test('Can error one of two .writable() on different file descriptors', async t => {281 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());282 const stream = subprocess.writable();283 const secondStream = subprocess.writable({to: 3});283 const secondStream = subprocess.writable({to: 'fd3'});284 const cause = new Error(foobarString);285 stream.destroy(cause);286 secondStream.end(foobarString);287
8 unmodified lines
296297test('Can error both .writable() on different file descriptors', async t => {298 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());299 const stream = subprocess.writable();300 const secondStream = subprocess.writable({to: 3});300 const secondStream = subprocess.writable({to: 'fd3'});301 const cause = new Error(foobarString);302 stream.destroy(cause);303 secondStream.destroy(cause);304
37 unmodified lines
342343test('Can error one of two .duplex() on different file descriptors', async t => {344 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());345 const stream = subprocess.duplex();346 const secondStream = subprocess.duplex({from: 'stderr', to: 3});346 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});347 const cause = new Error(foobarString);348 stream.destroy(cause);349 secondStream.end(foobarString);350
7 unmodified lines
358359test('Can error both .duplex() on different file descriptors', async t => {360 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());361 const stream = subprocess.duplex();362 const secondStream = subprocess.duplex({from: 'stderr', to: 3});362 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});363 const cause = new Error(foobarString);364 stream.destroy(cause);365 secondStream.destroy(cause);366
6 unmodified lines
modified:test/convert/duplex.js+7 added-7 removed
46 unmodified lines
47 await assertStreamOutput(t, stream, hasResult ? foobarString : '');48 await assertSubprocessOutput(t, subprocess, foobarString, fdNumber);49};5051test('.duplex() can use stdout', testReadableDuplexDefault, 1, 1, {}, true);52test('.duplex() can use stderr', testReadableDuplexDefault, 2, 2, {}, true);53test('.duplex() can use output stdio[*]', testReadableDuplexDefault, 3, 3, fullStdio, true);51test('.duplex() can use stdout', testReadableDuplexDefault, 1, 'stdout', {}, true);52test('.duplex() can use stderr', testReadableDuplexDefault, 2, 'stderr', {}, true);53test('.duplex() can use output stdio[*]', testReadableDuplexDefault, 3, 'fd3', fullStdio, true);54test('.duplex() uses stdout by default', testReadableDuplexDefault, 1, undefined, {}, true);55test('.duplex() does not use stderr by default', testReadableDuplexDefault, 2, undefined, {}, false);56test('.duplex() does not use stdio[*] by default', testReadableDuplexDefault, 3, undefined, fullStdio, false);57test('.duplex() uses stdout even if stderr is "ignore"', testReadableDuplexDefault, 1, 1, {stderr: 'ignore'}, true);58test('.duplex() uses stderr even if stdout is "ignore"', testReadableDuplexDefault, 2, 2, {stdout: 'ignore'}, true);57test('.duplex() uses stdout even if stderr is "ignore"', testReadableDuplexDefault, 1, 'stdout', {stderr: 'ignore'}, true);58test('.duplex() uses stderr even if stdout is "ignore"', testReadableDuplexDefault, 2, 'stderr', {stdout: 'ignore'}, true);59test('.duplex() uses stdout if "all" is used', testReadableDuplexDefault, 1, 'all', {all: true}, true);60test('.duplex() uses stderr if "all" is used', testReadableDuplexDefault, 2, 'all', {all: true}, true);6162const testWritableDuplexDefault = async (t, fdNumber, to, options) => {
5 unmodified lines
68 await assertStreamOutput(t, stream, foobarString);69 await assertSubprocessOutput(t, subprocess);70};7172test('.duplex() can use stdin', testWritableDuplexDefault, 0, 0, {});73test('.duplex() can use input stdio[*]', testWritableDuplexDefault, 3, 3, fullReadableStdio());72test('.duplex() can use stdin', testWritableDuplexDefault, 0, 'stdin', {});73test('.duplex() can use input stdio[*]', testWritableDuplexDefault, 3, 'fd3', fullReadableStdio());74test('.duplex() uses stdin by default', testWritableDuplexDefault, 0, undefined, {});7576test('.duplex() abort -> subprocess fail', async t => {77 const subprocess = getReadWriteSubprocess();
111 unmodified lines
modified:test/convert/readable.js+5 added-5 removed
49 unmodified lines
50 await assertStreamOutput(t, stream, hasResult ? foobarString : '');51 await assertSubprocessOutput(t, subprocess, foobarString, fdNumber);52};5354test('.readable() can use stdout', testReadableDefault, 1, 1, {}, true);55test('.readable() can use stderr', testReadableDefault, 2, 2, {}, true);56test('.readable() can use stdio[*]', testReadableDefault, 3, 3, fullStdio, true);54test('.readable() can use stdout', testReadableDefault, 1, 'stdout', {}, true);55test('.readable() can use stderr', testReadableDefault, 2, 'stderr', {}, true);56test('.readable() can use stdio[*]', testReadableDefault, 3, 'fd3', fullStdio, true);57test('.readable() uses stdout by default', testReadableDefault, 1, undefined, {}, true);58test('.readable() does not use stderr by default', testReadableDefault, 2, undefined, {}, false);59test('.readable() does not use stdio[*] by default', testReadableDefault, 3, undefined, fullStdio, false);60test('.readable() uses stdout even if stderr is "ignore"', testReadableDefault, 1, 1, {stderr: 'ignore'}, true);61test('.readable() uses stderr even if stdout is "ignore"', testReadableDefault, 2, 2, {stdout: 'ignore'}, true);60test('.readable() uses stdout even if stderr is "ignore"', testReadableDefault, 1, 'stdout', {stderr: 'ignore'}, true);61test('.readable() uses stderr even if stdout is "ignore"', testReadableDefault, 2, 'stderr', {stdout: 'ignore'}, true);62test('.readable() uses stdout if "all" is used', testReadableDefault, 1, 'all', {all: true}, true);63test('.readable() uses stderr if "all" is used', testReadableDefault, 2, 'all', {all: true}, true);6465const testBuffering = async (t, methodName) => {
389 unmodified lines
modified:test/convert/writable.js+2 added-2 removed
55 unmodified lines
56 await finishedStream(stream);57 await assertSubprocessOutput(t, subprocess);58};5960test('.writable() can use stdin', testWritableDefault, 0, 0, {});61test('.writable() can use stdio[*]', testWritableDefault, 3, 3, fullReadableStdio());60test('.writable() can use stdin', testWritableDefault, 0, 'stdin', {});61test('.writable() can use stdio[*]', testWritableDefault, 3, 'fd3', fullReadableStdio());62test('.writable() uses stdin by default', testWritableDefault, 0, undefined, {});6364test('.writable() hangs until ended', async t => {65 const subprocess = getReadWriteSubprocess();
324 unmodified lines
modified:test/pipe/setup.js+5 added-5 removed
13 unmodified lines
14};1516test('pipe(...) can pipe', pipeToSubprocess, 1, 0);17test('pipe(..., {from: "stdout"}) can pipe', pipeToSubprocess, 1, 0, 'stdout');18test('pipe(..., {from: 1}) can pipe', pipeToSubprocess, 1, 0, 1);18test('pipe(..., {from: "fd1"}) can pipe', pipeToSubprocess, 1, 0, 'fd1');19test('pipe(..., {from: "stderr"}) can pipe stderr', pipeToSubprocess, 2, 0, 'stderr');20test('pipe(..., {from: 2}) can pipe', pipeToSubprocess, 2, 0, 2);21test('pipe(..., {from: 3}) can pipe', pipeToSubprocess, 3, 0, 3, undefined, fullStdio);20test('pipe(..., {from: "fd2"}) can pipe', pipeToSubprocess, 2, 0, 'fd2');21test('pipe(..., {from: "fd3"}) can pipe', pipeToSubprocess, 3, 0, 'fd3', undefined, fullStdio);22test('pipe(..., {from: "all"}) can pipe stdout', pipeToSubprocess, 1, 0, 'all', undefined, {all: true});23test('pipe(..., {from: "all"}) can pipe stderr', pipeToSubprocess, 2, 0, 'all', undefined, {all: true});24test('pipe(..., {from: "all"}) can pipe stdout even with "stderr: ignore"', pipeToSubprocess, 1, 0, 'all', undefined, {all: true, stderr: 'ignore'});25test('pipe(..., {from: "all"}) can pipe stderr even with "stdout: ignore"', pipeToSubprocess, 2, 0, 'all', undefined, {all: true, stdout: 'ignore'});26test('pipe(..., {to: "stdin"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'stdin');27test('pipe(..., {to: 0}) can pipe', pipeToSubprocess, 1, 0, undefined, 0);28test('pipe(..., {to: 3}) can pipe', pipeToSubprocess, 1, 3, undefined, 3, {}, fullReadableStdio());27test('pipe(..., {to: "fd0"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'fd0');28test('pipe(..., {to: "fd3"}) can pipe', pipeToSubprocess, 1, 3, undefined, 'fd3', {}, fullReadableStdio());
modified:test/pipe/streaming.js+1 added-1 removed
90 unmodified lines
91test('Can pipe same source to two streams from same subprocess', async t => {92 const source = execa('noop-fd.js', ['1', foobarString]);93 const destination = execa('stdin-fd-both.js', ['3'], fullReadableStdio());94 const pipePromise = source.pipe(destination);95 const secondPipePromise = source.pipe(destination, {to: 3});95 const secondPipePromise = source.pipe(destination, {to: 'fd3'});9697 t.like(await source, {stdout: foobarString});98 t.like(await destination, {stdout: `${foobarString}${foobarString}`});99 t.is(await pipePromise, await destination);
342 unmodified lines
modified:test/pipe/validate.js+80 added-38 removed
131 unmodified lines
132test('.duplex() "to" option cannot be any string', testNodeStream, {133 to: 'other',134 message: 'must be "stdin"',135});136test('.pipe() "from" option cannot be a number without "fd"', testPipeError, {137 from: '1',138 message: 'must be "stdout", "stderr", "all"',139});140test('.duplex() "from" option cannot be a number without "fd"', testNodeStream, {141 from: '1',142 message: 'must be "stdout", "stderr", "all"',143});144test('.pipe() "to" option cannot be a number without "fd"', testPipeError, {145 to: '0',146 message: 'must be "stdin"',147});148test('.duplex() "to" option cannot be a number without "fd"', testNodeStream, {149 to: '0',150 message: 'must be "stdin"',151});152test('.pipe() "from" option cannot be just "fd"', testPipeError, {153 from: 'fd',154 message: 'must be "stdout", "stderr", "all"',155});156test('.duplex() "from" option cannot be just "fd"', testNodeStream, {157 from: 'fd',158 message: 'must be "stdout", "stderr", "all"',159});160test('.pipe() "to" option cannot be just "fd"', testPipeError, {161 to: 'fd',162 message: 'must be "stdin"',163});164test('.duplex() "to" option cannot be just "fd"', testNodeStream, {165 to: 'fd',166 message: 'must be "stdin"',167});168test('.pipe() "from" option cannot be a float', testPipeError, {137 from: 1.5,169 from: 'fd1.5',170 message: 'must be "stdout", "stderr", "all"',171});172test('.duplex() "from" option cannot be a float', testNodeStream, {141 from: 1.5,173 from: 'fd1.5',174 message: 'must be "stdout", "stderr", "all"',175});176test('.pipe() "to" option cannot be a float', testPipeError, {145 to: 1.5,177 to: 'fd1.5',178 message: 'must be "stdin"',179});180test('.duplex() "to" option cannot be a float', testNodeStream, {149 to: 1.5,181 to: 'fd1.5',182 message: 'must be "stdin"',183});184test('.pipe() "from" option cannot be a negative number', testPipeError, {153 from: -1,185 from: 'fd-1',186 message: 'must be "stdout", "stderr", "all"',187});188test('.duplex() "from" option cannot be a negative number', testNodeStream, {157 from: -1,189 from: 'fd-1',190 message: 'must be "stdout", "stderr", "all"',191});192test('.pipe() "to" option cannot be a negative number', testPipeError, {161 to: -1,193 to: 'fd-1',194 message: 'must be "stdin"',195});196test('.duplex() "to" option cannot be a negative number', testNodeStream, {165 to: -1,197 to: 'fd-1',198 message: 'must be "stdin"',199});200test('.pipe() "from" option cannot be a non-existing file descriptor', testPipeError, {169 from: 3,201 from: 'fd3',202 message: 'file descriptor does not exist',203});204test('.duplex() "from" cannot be a non-existing file descriptor', testNodeStream, {173 from: 3,205 from: 'fd3',206 message: 'file descriptor does not exist',207});208test('.pipe() "to" option cannot be a non-existing file descriptor', testPipeError, {177 to: 3,209 to: 'fd3',210 message: 'file descriptor does not exist',211});212test('.duplex() "to" cannot be a non-existing file descriptor', testNodeStream, {181 to: 3,213 to: 'fd3',214 message: 'file descriptor does not exist',215});216test('.pipe() "from" option cannot be an input file descriptor', testPipeError, {217 sourceOptions: getStdio(3, new Uint8Array()),186 from: 3,218 from: 'fd3',219 message: 'must be a readable stream',220});221test('.duplex() "from" option cannot be an input file descriptor', testNodeStream, {222 sourceOptions: getStdio(3, new Uint8Array()),191 from: 3,223 from: 'fd3',224 message: 'must be a readable stream',225});226test('.pipe() "to" option cannot be an output file descriptor', testPipeError, {227 destinationOptions: fullStdio,196 to: 3,228 to: 'fd3',229 message: 'must be a writable stream',230});231test('.duplex() "to" option cannot be an output file descriptor', testNodeStream, {232 sourceOptions: fullStdio,201 to: 3,233 to: 'fd3',234 message: 'must be a writable stream',235});236test('.pipe() "to" option cannot be "all"', testPipeError, {237 destinationOptions: fullStdio,238 to: 'all',239 message: 'must be a writable stream',240});241test('.duplex() "to" option cannot be "all"', testNodeStream, {242 sourceOptions: fullStdio,243 to: 'all',244 message: 'must be a writable stream',245});246test('Cannot set "stdout" option to "ignore" to use .pipe()', testPipeError, {247 sourceOptions: {stdout: 'ignore'},248 message: ['stdout', '\'ignore\''],249});
11 unmodified lines
261 writable: true,262});263test('Cannot set "stdout" option to "ignore" to use .pipe(1)', testPipeError, {264 sourceOptions: {stdout: 'ignore'},223 from: 1,265 from: 'fd1',266 message: ['stdout', '\'ignore\''],267});268test('Cannot set "stdout" option to "ignore" to use .duplex(1)', testNodeStream, {269 sourceOptions: {stdout: 'ignore'},228 from: 1,270 from: 'fd1',271 message: ['stdout', '\'ignore\''],272});273test('Cannot set "stdin" option to "ignore" to use .pipe(0)', testPipeError, {274 destinationOptions: {stdin: 'ignore'},275 message: ['stdin', '\'ignore\''],234 to: 0,276 to: 'fd0',277});278test('Cannot set "stdin" option to "ignore" to use .duplex(0)', testNodeStream, {279 sourceOptions: {stdin: 'ignore'},280 message: ['stdin', '\'ignore\''],239 to: 0,281 to: 'fd0',282});283test('Cannot set "stdout" option to "ignore" to use .pipe("stdout")', testPipeError, {284 sourceOptions: {stdout: 'ignore'},285 from: 'stdout',
23 unmodified lines
309 message: ['stdout', '\'ignore\''],310});311test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(1)', testPipeError, {312 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},271 from: 1,313 from: 'fd1',314 message: ['stdout', '\'ignore\''],315});316test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex(1)', testNodeStream, {317 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},276 from: 1,318 from: 'fd1',319 message: ['stdout', '\'ignore\''],320});321test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stdout")', testPipeError, {322 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},
23 unmodified lines
346 writable: true,347});348test('Cannot set "stdio[1]" option to "ignore" to use .pipe(1)', testPipeError, {349 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},308 from: 1,350 from: 'fd1',351 message: ['stdio[1]', '\'ignore\''],352});353test('Cannot set "stdio[1]" option to "ignore" to use .duplex(1)', testNodeStream, {354 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},313 from: 1,355 from: 'fd1',356 message: ['stdio[1]', '\'ignore\''],357});358test('Cannot set "stdio[0]" option to "ignore" to use .pipe(0)', testPipeError, {359 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},360 message: ['stdio[0]', '\'ignore\''],319 to: 0,361 to: 'fd0',362});363test('Cannot set "stdio[0]" option to "ignore" to use .duplex(0)', testNodeStream, {364 sourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},365 message: ['stdio[0]', '\'ignore\''],324 to: 0,366 to: 'fd0',367});368test('Cannot set "stdio[1]" option to "ignore" to use .pipe("stdout")', testPipeError, {369 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},370 from: 'stdout',
15 unmodified lines
386 to: 'stdin',387});388test('Cannot set "stderr" option to "ignore" to use .pipe(2)', testPipeError, {389 sourceOptions: {stderr: 'ignore'},348 from: 2,390 from: 'fd2',391 message: ['stderr', '\'ignore\''],392});393test('Cannot set "stderr" option to "ignore" to use .duplex(2)', testNodeStream, {394 sourceOptions: {stderr: 'ignore'},353 from: 2,395 from: 'fd2',396 message: ['stderr', '\'ignore\''],397});398test('Cannot set "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {399 sourceOptions: {stderr: 'ignore'},
6 unmodified lines
406 message: ['stderr', '\'ignore\''],407});408test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(2)', testPipeError, {409 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},368 from: 2,410 from: 'fd2',411 message: ['stderr', '\'ignore\''],412});413test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex(2)', testNodeStream, {414 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},373 from: 2,415 from: 'fd2',416 message: ['stderr', '\'ignore\''],417});418test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {419 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},
6 unmodified lines
426 message: ['stderr', '\'ignore\''],427});428test('Cannot set "stdio[2]" option to "ignore" to use .pipe(2)', testPipeError, {429 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},388 from: 2,430 from: 'fd2',431 message: ['stdio[2]', '\'ignore\''],432});433test('Cannot set "stdio[2]" option to "ignore" to use .duplex(2)', testNodeStream, {434 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},393 from: 2,435 from: 'fd2',436 message: ['stdio[2]', '\'ignore\''],437});438test('Cannot set "stdio[2]" option to "ignore" to use .pipe("stderr")', testPipeError, {439 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},
6 unmodified lines
446 message: ['stdio[2]', '\'ignore\''],447});448test('Cannot set "stdio[3]" option to "ignore" to use .pipe(3)', testPipeError, {449 sourceOptions: getStdio(3, 'ignore'),408 from: 3,450 from: 'fd3',451 message: ['stdio[3]', '\'ignore\''],452});453test('Cannot set "stdio[3]" option to "ignore" to use .duplex(3)', testNodeStream, {454 sourceOptions: getStdio(3, 'ignore'),413 from: 3,455 from: 'fd3',456 message: ['stdio[3]', '\'ignore\''],457});458test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("all")', testPipeError, {459 sourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},
85 unmodified lines
545});546test('Cannot set "stdio[3]" option to Node.js Writable streams to use .pipe()', testPipeError, {547 sourceOptions: getStdio(3, process.stdout),548 message: ['stdio[3]', 'Stream'],507 from: 3,549 from: 'fd3',550});551test('Cannot set "stdio[3]" option to Node.js Writable streams to use .duplex()', testNodeStream, {552 sourceOptions: getStdio(3, process.stdout),553 message: ['stdio[3]', 'Stream'],512 from: 3,554 from: 'fd3',555});556test('Cannot set "stdio[3]" option to Node.js Readable streams to use .pipe()', testPipeError, {557 destinationOptions: getStdio(3, process.stdin),558 message: ['stdio[3]', 'Stream'],517 to: 3,559 to: 'fd3',560});561test('Cannot set "stdio[3]" option to Node.js Readable streams to use .duplex()', testNodeStream, {562 sourceOptions: getStdio(3, process.stdin),563 message: ['stdio[3]', 'Stream'],522 to: 3,564 to: 'fd3',565});566567test('Destination stream is ended when first argument is invalid', async t => {568 const source = execa('empty.js', {stdout: 'ignore'});
58 unmodified lines
modified:index.d.ts+7 added-6 removed
903 unmodified lines
904type AllIfStderr<StderrResultIgnored extends boolean> = StderrResultIgnored extends true905 ? undefined906 : Readable;907908type FromOption = 'stdout' | 'stderr' | 'all' | number;909type ToOption = 'stdin' | number;908type FileDescriptorOption = `fd${number}`;909type FromOption = 'stdout' | 'stderr' | 'all' | FileDescriptorOption;910type ToOption = 'stdin' | FileDescriptorOption;911912type PipeOptions = {913 /**913 Which stream to pipe from the source subprocess. A file descriptor number can also be passed.914 Which stream to pipe from the source subprocess. A file descriptor like `"fd3"` can also be passed.915916 `"all"` pipes both `stdout` and `stderr`. This requires the `all` option to be `true`.917 */918 readonly from?: FromOption;919920 /**920 Which stream to pipe to the destination subprocess. A file descriptor number can also be passed.921 Which stream to pipe to the destination subprocess. A file descriptor like `"fd3"` can also be passed.922 */923 readonly to?: ToOption;924925 /**
47 unmodified lines
973};974975type ReadableStreamOptions = {976 /**976 Which stream to read from the subprocess. A file descriptor number can also be passed.977 Which stream to read from the subprocess. A file descriptor like `"fd3"` can also be passed.978979 `"all"` reads both `stdout` and `stderr`. This requires the `all` option to be `true`.980 */981 readonly from?: FromOption;982};983984type WritableStreamOptions = {985 /**985 Which stream to write to the subprocess. A file descriptor number can also be passed.986 Which stream to write to the subprocess. A file descriptor like `"fd3"` can also be passed.987 */988 readonly to?: ToOption;989};990
539 unmodified lines
modified:index.test-d.ts+35 added-17 removed
86 unmodified lines
87 const bufferResult = await execaBufferPromise;8889 const scriptPromise = $`unicorns`;9091 const pipeOptions = {from: 'stderr', to: 3, all: true} as const;91 const pipeOptions = {from: 'stderr', to: 'fd3', all: true} as const;9293 type BufferExecaReturnValue = typeof bufferResult;94 type EmptyExecaReturnValue = ExecaResult<{}>;95 type ShortcutExecaReturnValue = ExecaResult<typeof pipeOptions>;
73 unmodified lines
169 await execaPromise.pipe({from: 'all'})`stdin`;170 await scriptPromise.pipe({from: 'all'})`stdin`;171 await execaPromise.pipe('stdin', {from: 'all'});172 await scriptPromise.pipe('stdin', {from: 'all'});173 await execaPromise.pipe(execaBufferPromise, {from: 3});174 await scriptPromise.pipe(execaBufferPromise, {from: 3});175 await execaPromise.pipe({from: 3})`stdin`;176 await scriptPromise.pipe({from: 3})`stdin`;177 await execaPromise.pipe('stdin', {from: 3});178 await scriptPromise.pipe('stdin', {from: 3});173 await execaPromise.pipe(execaBufferPromise, {from: 'fd3'});174 await scriptPromise.pipe(execaBufferPromise, {from: 'fd3'});175 await execaPromise.pipe({from: 'fd3'})`stdin`;176 await scriptPromise.pipe({from: 'fd3'})`stdin`;177 await execaPromise.pipe('stdin', {from: 'fd3'});178 await scriptPromise.pipe('stdin', {from: 'fd3'});179 expectError(execaPromise.pipe(execaBufferPromise, {from: 'stdin'}));180 expectError(scriptPromise.pipe(execaBufferPromise, {from: 'stdin'}));181 expectError(execaPromise.pipe({from: 'stdin'})`stdin`);182 expectError(scriptPromise.pipe({from: 'stdin'})`stdin`);
4 unmodified lines
187 await execaPromise.pipe({to: 'stdin'})`stdin`;188 await scriptPromise.pipe({to: 'stdin'})`stdin`;189 await execaPromise.pipe('stdin', {to: 'stdin'});190 await scriptPromise.pipe('stdin', {to: 'stdin'});191 await execaPromise.pipe(execaBufferPromise, {to: 3});192 await scriptPromise.pipe(execaBufferPromise, {to: 3});193 await execaPromise.pipe({to: 3})`stdin`;194 await scriptPromise.pipe({to: 3})`stdin`;195 await execaPromise.pipe('stdin', {to: 3});196 await scriptPromise.pipe('stdin', {to: 3});191 await execaPromise.pipe(execaBufferPromise, {to: 'fd3'});192 await scriptPromise.pipe(execaBufferPromise, {to: 'fd3'});193 await execaPromise.pipe({to: 'fd3'})`stdin`;194 await scriptPromise.pipe({to: 'fd3'})`stdin`;195 await execaPromise.pipe('stdin', {to: 'fd3'});196 await scriptPromise.pipe('stdin', {to: 'fd3'});197 expectError(execaPromise.pipe(execaBufferPromise, {to: 'stdout'}));198 expectError(scriptPromise.pipe(execaBufferPromise, {to: 'stdout'}));199 expectError(execaPromise.pipe({to: 'stdout'})`stdin`);200 expectError(scriptPromise.pipe({to: 'stdout'})`stdin`);
33 unmodified lines
234 expectError(await execaPromise.pipe('stdin', [false]));235 expectError(await execaPromise.pipe('stdin', [], false));236 expectError(await execaPromise.pipe('stdin', {other: true}));237 expectError(await execaPromise.pipe('stdin', [], {other: true}));238 expectError(await execaPromise.pipe('stdin', {from: 'fd'}));239 expectError(await execaPromise.pipe('stdin', [], {from: 'fd'}));240 expectError(await execaPromise.pipe('stdin', {from: 'fdNotANumber'}));241 expectError(await execaPromise.pipe('stdin', [], {from: 'fdNotANumber'}));242 expectError(await execaPromise.pipe('stdin', {from: 'other'}));243 expectError(await execaPromise.pipe('stdin', [], {from: 'other'}));244 expectError(await execaPromise.pipe('stdin', {to: 'fd'}));245 expectError(await execaPromise.pipe('stdin', [], {to: 'fd'}));246 expectError(await execaPromise.pipe('stdin', {to: 'fdNotANumber'}));247 expectError(await execaPromise.pipe('stdin', [], {to: 'fdNotANumber'}));248 expectError(await execaPromise.pipe('stdin', {to: 'other'}));249 expectError(await execaPromise.pipe('stdin', [], {to: 'other'}));250251 const pipeResult = await execaPromise.pipe`stdin`;252 expectType<string>(pipeResult.stdout);253 const ignorePipeResult = await execaPromise.pipe({stdout: 'ignore'})`stdin`;
21 unmodified lines
275 scriptPromise.readable({});276 scriptPromise.readable({from: 'stdout'});277 scriptPromise.readable({from: 'stderr'});278 scriptPromise.readable({from: 'all'});269 scriptPromise.readable({from: 3});279 scriptPromise.readable({from: 'fd3'});280 expectError(scriptPromise.readable('stdout'));281 expectError(scriptPromise.readable({from: 'stdin'}));282 expectError(scriptPromise.readable({from: 'fd'}));283 expectError(scriptPromise.readable({from: 'fdNotANumber'}));284 expectError(scriptPromise.readable({other: 'stdout'}));285 scriptPromise.writable({});286 scriptPromise.writable({to: 'stdin'});275 scriptPromise.writable({to: 3});287 scriptPromise.writable({to: 'fd3'});288 expectError(scriptPromise.writable('stdin'));289 expectError(scriptPromise.writable({to: 'stdout'}));290 expectError(scriptPromise.writable({to: 'fd'}));291 expectError(scriptPromise.writable({to: 'fdNotANumber'}));292 expectError(scriptPromise.writable({other: 'stdin'}));293 scriptPromise.duplex({});294 scriptPromise.duplex({from: 'stdout'});295 scriptPromise.duplex({from: 'stderr'});296 scriptPromise.duplex({from: 'all'});283 scriptPromise.duplex({from: 3});297 scriptPromise.duplex({from: 'fd3'});298 scriptPromise.duplex({from: 'stdout', to: 'stdin'});285 scriptPromise.duplex({from: 'stdout', to: 3});299 scriptPromise.duplex({from: 'stdout', to: 'fd3'});300 expectError(scriptPromise.duplex('stdout'));301 expectError(scriptPromise.duplex({from: 'stdin'}));302 expectError(scriptPromise.duplex({from: 'stderr', to: 'stdout'}));303 expectError(scriptPromise.duplex({from: 'fd'}));304 expectError(scriptPromise.duplex({from: 'fdNotANumber'}));305 expectError(scriptPromise.duplex({to: 'fd'}));306 expectError(scriptPromise.duplex({to: 'fdNotANumber'}));307 expectError(scriptPromise.duplex({other: 'stdout'}));308309 expectType<Readable>(execaPromise.all);310 const noAllPromise = execa('unicorns');
1350 unmodified lines
modified:readme.md+8 added-8 removed
399 unmodified lines
400Type: `object`401402##### pipeOptions.from403404Type: `"stdout" | "stderr" | "all" | number`\404Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\405Default: `"stdout"`406407Which stream to pipe from the source subprocess. A file descriptor number can also be passed.407Which stream to pipe from the source subprocess. A file descriptor like `"fd3"` can also be passed.408409`"all"` pipes both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.410411##### pipeOptions.to412413Type: `"stdin" | number`\413Type: `"stdin" | "fd3" | "fd4" | ...`\414Default: `"stdin"`415416Which stream to pipe to the destination subprocess. A file descriptor number can also be passed.416Which stream to pipe to the destination subprocess. A file descriptor like `"fd3"` can also be passed.417418##### pipeOptions.unpipeSignal419420Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
55 unmodified lines
476Type: `object`477478##### streamOptions.from479480Type: `"stdout" | "stderr" | "all" | number`\480Type: `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\481Default: `"stdout"`482483Which stream to read from the subprocess. A file descriptor number can also be passed.483Which stream to read from the subprocess. A file descriptor like `"fd3"` can also be passed.484485`"all"` reads both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.486487Only available with [`.readable()`](#readablestreamoptions) and [`.duplex()`](#duplexstreamoptions), not [`.writable()`](#writablestreamoptions).488489##### streamOptions.to490491Type: `"stdin" | number`\491Type: `"stdin" | "fd3" | "fd4" | ...`\492Default: `"stdin"`493494Which stream to write to the subprocess. A file descriptor number can also be passed.494Which stream to write to the subprocess. A file descriptor like `"fd3"` can also be passed.495496Only available with [`.writable()`](#writablestreamoptions) and [`.duplex()`](#duplexstreamoptions), not [`.readable()`](#readablestreamoptions).497498### SubprocessResult
662 unmodified lines