Upgrade `is-stream` to `4.0.1` (#835)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 28acdbc · Browse files · 7 files·+28 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+28 added−16 removed
- tests:+1 added−1 removed
- other:+27 added−15 removed
Provenance
- Commit
9cd62aa- Tree
00b423a- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
28acdbc
7 files changed+28 added−16 removed
modified:lib/stdio/direction.js+22 added-10 removed
36 unmodified lines3738394041424142434445464547484950515248495354555657525354555658596061626364656667686970717273747576773 unmodified lines36 unmodified lines iterable: alwaysInput, uint8Array: alwaysInput, webStream: stdioOption => isWritableStream(stdioOption) ? 'output' : 'input', nodeStream(stdioOption) { if (isNodeReadableStream(stdioOption)) { return isNodeWritableStream(stdioOption) ? undefined : 'input'; const standardStreamDirection = getStandardStreamDirection(stdioOption); if (standardStreamDirection !== undefined) { return standardStreamDirection; }
if (!isNodeReadableStream(stdioOption, {checkOpen: false})) { return 'output'; return 'output'; }
return isNodeWritableStream(stdioOption, {checkOpen: false}) ? undefined : 'input'; }, native(stdioOption) { if ([0, process.stdin].includes(stdioOption)) { return 'input'; const standardStreamDirection = getStandardStreamDirection(stdioOption); if (standardStreamDirection !== undefined) { return standardStreamDirection; }
if ([1, 2, process.stdout, process.stderr].includes(stdioOption)) { return 'output'; }
if (isNodeStream(stdioOption)) { if (isNodeStream(stdioOption, {checkOpen: false})) { return guessStreamDirection.nodeStream(stdioOption); } },};
const getStandardStreamDirection = stdioOption => { if ([0, process.stdin].includes(stdioOption)) { return 'input'; }
if ([1, 2, process.stdout, process.stderr].includes(stdioOption)) { return 'output'; }};
const addDirection = (stdioStream, direction = DEFAULT_DIRECTION) => ({...stdioStream, direction});
// When ambiguous, we initially keep the direction as `undefined`.// This allows arrays of `stdio` values to resolve the ambiguity.3 unmodified linesmodified:lib/stdio/input.js+1 added-1 removed
14 unmodified lines1516171819192021222327 unmodified lines14 unmodified lines index: 0,};
const getInputType = input => { if (isReadableStream(input)) { if (isReadableStream(input, {checkOpen: false})) { return 'nodeStream'; }
if (typeof input === 'string') {27 unmodified linesmodified:lib/stdio/native.js+1 added-1 removed
21 unmodified lines2223242526262728293016 unmodified lines21 unmodified lines if (typeof value === 'number') { return {...stdioStream, type: 'nodeStream', value: getStandardStream(value, value, optionName)}; }
if (isNodeStream(value)) { if (isNodeStream(value, {checkOpen: false})) { return {...stdioStream, type: 'nodeStream'}; }
return stdioStream;16 unmodified linesmodified:lib/stdio/type.js+1 added-1 removed
17 unmodified lines18 if (isWebStream(stdioOption)) {19 return 'webStream';20 }21 22- if (isNodeStream(stdioOption)) {22+ if (isNodeStream(stdioOption, {checkOpen: false})) {23 return 'native';24 }25 26 if (isUint8Array(stdioOption)) {74 unmodified linesmodified:lib/stream.js+1 added-1 removed
128 unmodified lines129 // Some `stdin`/`stdout`/`stderr` options create a stream, e.g. when passing a file path.130 // The `.pipe()` method automatically ends that stream when `childProcess` ends.131 // This makes sure we wait for the completion of those streams, in order to catch any error.132 const waitForCustomStreamsEnd = (stdioStreamsGroups, streamInfo) => stdioStreamsGroups.flatMap((stdioStreams, index) => stdioStreams133- .filter(({value}) => isStream(value) && !isStandardStream(value))133+ .filter(({value}) => isStream(value, {checkOpen: false}) && !isStandardStream(value))134 .map(({type, value}) => waitForStream(value, index, streamInfo, {135 isSameDirection: type === 'generator',136 stopOnExit: type === 'native',137 })));83 unmodified linesmodified:test/stdio/node-stream.js+1 added-1 removed
245 unmodified lines246 247 const testInputDuplexStream = async (t, index) => {248 const stream = new PassThrough();249 stream.end(foobarString);250- const {stdout} = await execa('stdin-fd.js', [`${index}`], getStdio(index, [stream, 'pipe']));250+ const {stdout} = await execa('stdin-fd.js', [`${index}`], getStdio(index, [stream, new Uint8Array()]));251 t.is(stdout, foobarString);252 };253 254 test('Can pass Duplex streams to stdin', testInputDuplexStream, 0);14 unmodified linesmodified:package.json+1 added-1 removed
47 unmodified lines48 "@sindresorhus/merge-streams": "^2.0.1",49 "cross-spawn": "^7.0.3",50 "get-stream": "^8.0.1",51 "human-signals": "^6.0.0",52- "is-stream": "^3.0.0",52+ "is-stream": "^4.0.1",53 "npm-run-path": "^5.2.0",54 "signal-exit": "^4.1.0",55 "strip-final-newline": "^4.0.0"56 },36 unmodified lines