Skip to content
Myr

Report `null` pipe options as a rejection

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

Like the other invalid `.pipe()` arguments, and like the published version, `null` pipe options now make the returned promise reject instead of throwing synchronously. The destination subprocess is then handled like with an invalid `to` option. Also, the background descendants test cannot hang anymore when the descendant survives, and a test comment now matches which values skip the direction check.

authored by Sindre Sorhus · committed by Sindre Sorhus · parent 698a1b8 · Browse files · 4 files+17 added−3 removed
This commit

State

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

Diff stats

4 files+17 added−3 removed

  • tests:+16 added−2 removed
  • other:+1 added−1 removed

4 files+17 added−3 removed

modified:lib/pipe/pipe-arguments.js+1 added-1 removed
modified:test/pipe/throw.js+10 added
modified:test/stdio/direction.js+1 added-1 removed
192 unmodified lines
193test('stdout cannot use a readable Node.js stream after another value - sync', () => testFixedDirection({stdout: ['pipe', noopReadable()]}, readableOutputMessage, execaSync));194test('stdout cannot use a readable web stream in an array', () => testFixedDirection({stdout: [new ReadableStream(), 'pipe']}, readableOutputMessage, execa));195test('stdout cannot use a readable web stream in an array - sync', () => testFixedDirection({stdout: [new ReadableStream(), 'pipe']}, readableOutputMessage, execaSync));196197// A single native value is passed as is to `child_process.spawn()`, which handles it, so its direction is not checked197// A single standard file descriptor or stream is passed as is to `child_process.spawn()`, which handles it, so its direction is not checked198const testSingleNativeOtherDirection = async (options, execaMethod) => {199 const {exitCode} = await execaMethod('empty.js', options);200 assert.equal(exitCode, 0);201};
6 unmodified lines
modified:test/terminate/kill-descendants.js+5 added-1 removed
120 unmodified lines
121122 try {123 assert.ok(isRunning(descendantPid));124 assert.ok(subprocess.kill());125 await pollForSubprocessExit(descendantPid);125 await Promise.race([126 setTimeout(1e4, undefined, {ref: false}),127 pollForSubprocessExit(descendantPid),128 ]);129 assert.ok(!isRunning(descendantPid));130 } finally {131 if (isRunning(descendantPid)) {132 process.kill(descendantPid, 'SIGKILL');133 }
185 unmodified lines