Skip to content
Myr

Rename `signal` option to `unpipeSignal` (#852)

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

authored by ehmicky · committed by GitHub · parent 46ba4b4 · Browse files · 8 files+26 added−26 removed
This commit

State

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

Diff stats

8 files+26 added−26 removed

  • tests:+9 added−9 removed
  • other:+17 added−17 removed

8 files+26 added−26 removed

modified:lib/pipe/abort.js+5 added-5 removed
modified:lib/pipe/setup.js+2 added-2 removed
modified:lib/pipe/validate.js+2 added-2 removed
modified:test/pipe/abort.js+8 added-8 removed
34 unmodified lines
35test('Can unpipe a single process', async t => {36 const abortController = new AbortController();37 const source = execa('stdin.js');38 const destination = execa('stdin.js');39 const pipePromise = source.pipe(destination, {signal: abortController.signal});39 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});4041 abortController.abort();42 await assertUnPipeError(t, pipePromise);43
8 unmodified lines
52 const abortController = new AbortController();53 abortController.abort();54 const source = execa('empty.js');55 const destination = execa('empty.js');56 const pipePromise = source.pipe(destination, {signal: abortController.signal});56 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});5758 await assertUnPipeError(t, pipePromise);59});60
1 unmodified line
62 const abortController = new AbortController();63 const source = execa('stdin.js');64 const secondSource = execa('noop.js', [foobarString]);65 const destination = execa('stdin.js');66 const pipePromise = source.pipe(destination, {signal: abortController.signal});66 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});67 const secondPipePromise = secondSource.pipe(destination);6869 abortController.abort();70 await assertUnPipeError(t, pipePromise);
9 unmodified lines
80test('Can unpipe a process among other sources on the same process', async t => {81 const abortController = new AbortController();82 const source = execa('stdin-both.js');83 const destination = execa('stdin.js');84 const pipePromise = source.pipe(destination, {signal: abortController.signal});84 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});85 const secondPipePromise = source.pipe(destination, {from: 'stderr'});8687 abortController.abort();88 await assertUnPipeError(t, pipePromise);
9 unmodified lines
98 const abortController = new AbortController();99 const source = execa('stdin.js');100 const destination = execa('stdin.js');101 const secondDestination = execa('stdin.js');102 const pipePromise = source.pipe(destination, {signal: abortController.signal});102 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});103 const secondPipePromise = source.pipe(secondDestination);104105 abortController.abort();106 await assertUnPipeError(t, pipePromise);
10 unmodified lines
117test('Can unpipe then re-pipe a process', async t => {118 const abortController = new AbortController();119 const source = execa('stdin.js');120 const destination = execa('stdin.js');121 const pipePromise = source.pipe(destination, {signal: abortController.signal});121 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});122123 source.stdin.write('.');124 const [firstWrite] = await once(source.stdout, 'data');125 t.is(firstWrite.toString(), '.');
11 unmodified lines
137test('Can unpipe to prevent termination to propagate to source', async t => {138 const abortController = new AbortController();139 const source = execa('stdin.js');140 const destination = execa('stdin.js');141 const pipePromise = source.pipe(destination, {signal: abortController.signal});141 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});142143 abortController.abort();144 await assertUnPipeError(t, pipePromise);145
7 unmodified lines
153test('Can unpipe to prevent termination to propagate to destination', async t => {154 const abortController = new AbortController();155 const source = execa('noop-forever.js', [foobarString]);156 const destination = execa('stdin.js');157 const pipePromise = source.pipe(destination, {signal: abortController.signal});157 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});158159 abortController.abort();160 await assertUnPipeError(t, pipePromise);161
6 unmodified lines
modified:test/pipe/streaming.js+1 added-1 removed
396 unmodified lines
397test('Does not return nor set pipedFrom on signal abort', async t => {398 const abortController = new AbortController();399 const source = execa('empty.js');400 const destination = execa('empty.js');401 const pipePromise = source.pipe(destination, {signal: abortController.signal});401 const pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});402403 abortController.abort();404 t.like(await t.throwsAsync(pipePromise), {pipedFrom: []});405 const destinationResult = await destination;
23 unmodified lines
modified:index.d.ts+1 added-1 removed
829 unmodified lines
830 Unpipe the child process when the signal aborts.831832 The `.pipe()` method will be rejected with a cancellation error.833 */834 readonly signal?: AbortSignal;834 readonly unpipeSignal?: AbortSignal;835};836837type PipableProcess = {838 /**
541 unmodified lines
modified:index.test-d.ts+6 added-6 removed
125 unmodified lines
126 await scriptPromise.pipe({from: 3})`stdin`;127 expectError(execaPromise.pipe(execaBufferPromise, {from: 'other'}));128 expectError(scriptPromise.pipe(execaBufferPromise, {from: 'other'}));129 expectError(scriptPromise.pipe({from: 'other'})`stdin`);130 await execaPromise.pipe(execaBufferPromise, {signal: new AbortController().signal});131 await scriptPromise.pipe(execaBufferPromise, {signal: new AbortController().signal});132 await scriptPromise.pipe({signal: new AbortController().signal})`stdin`;133 expectError(await execaPromise.pipe(execaBufferPromise, {signal: true}));134 expectError(await scriptPromise.pipe(execaBufferPromise, {signal: true}));135 expectError(await scriptPromise.pipe({signal: true})`stdin`);130 await execaPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});131 await scriptPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});132 await scriptPromise.pipe({unpipeSignal: new AbortController().signal})`stdin`;133 expectError(await execaPromise.pipe(execaBufferPromise, {unpipeSignal: true}));134 expectError(await scriptPromise.pipe(execaBufferPromise, {unpipeSignal: true}));135 expectError(await scriptPromise.pipe({unpipeSignal: true})`stdin`);136 expectError(await scriptPromise.pipe({})({}));137 expectError(await scriptPromise.pipe({})(execaPromise));138139 const pipeResult = await scriptPromise.pipe`stdin`;
1326 unmodified lines
modified:readme.md+1 added-1 removed
361 unmodified lines
362Which stream to pipe. A file descriptor number can also be passed.363364`"all"` pipes both `stdout` and `stderr`. This requires the [`all` option](#all-2) to be `true`.365366##### pipeOptions.signal366##### pipeOptions.unpipeSignal367368Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)369370Unpipe the child process when the signal aborts.
643 unmodified lines