Skip to content
Myr

Fix input with inherited stdin (#1232)

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

authored by Puneet Dixit · committed by GitHub · parent f3a2e84 · Browse files · 3 files+43 added−2 removed
This commit

State

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

Diff stats

3 files+43 added−2 removed

  • tests:+32 added−0 removed
  • other:+11 added−2 removed

3 files+43 added−2 removed

modified:lib/stdio/handle.js+11 added-2 removed
59 unmodified lines
60// This is what users would expect.61// For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.62const initializeStdioItems = ({stdioOption, fdNumber, options, optionName}) => {63 const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];64 const inputStdioItems = handleInputOptions(options, fdNumber);65 const initialStdioItems = [65 ...values.map(value => initializeStdioItem(value, optionName)),66 ...handleInputOptions(options, fdNumber),66 ...omitInheritedStdin(values.map(value => initializeStdioItem(value, optionName)), inputStdioItems),67 ...inputStdioItems,68 ];6970 const stdioItems = filterDuplicates(initialStdioItems);71 const isStdioArray = stdioItems.length > 1;
1 unmodified line
73 validateStreams(stdioItems);74 return {stdioItems, isStdioArray};75};7677const omitInheritedStdin = (stdioItems, inputStdioItems) => inputStdioItems.length > 0 && isInheritedStdinOnly(stdioItems)78 ? []79 : stdioItems;8081const isInheritedStdinOnly = stdioItems => stdioItems.length === 182 && stdioItems[0].type === 'native'83 && stdioItems[0].value === 'inherit';8485const initializeStdioItem = (value, optionName) => ({86 type: getStdioItemType(value, optionName),87 value,88 optionName,
135 unmodified lines
added:test/fixtures/nested-input-inherit.js+17 added
modified:test/io/input-option.js+15 added