stdio.js
This file
Path
lib/stdio.js
49 lines · 1.1 KiB · JavaScript
Last changed by
Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
History of this fileTake it
The walk stopped after 200 commits: lines older than 27441fa point at it.
Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
line 1why, one step back1const aliases = ['stdin', 'stdout', 'stderr'];Add a logo (#201)ehmickybefore adoption27441fa
line 2why, one step back2Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 3why, one step back3const hasAlias = options => aliases.some(alias => options[alias] !== undefined);Add a logo (#201)ehmickybefore adoption27441fa
line 4why, one step back4Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 5why, one step back5export const normalizeStdio = options => {Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 6why, one step back6 if (!options) {Add a logo (#201)ehmickybefore adoption27441fa
lines 7–9why, one step back7 return;8 }9Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 10why, one step back10 const {stdio} = options;Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 11–12why, one step back1112 if (stdio === undefined) {Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 13why, one step back13 return aliases.map(alias => options[alias]);Add a logo (#201)ehmickybefore adoption27441fa
lines 14–15why, one step back14 }15Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 16why, one step back16 if (hasAlias(options)) {Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
line 17why, one step back17 throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);Add a logo (#201)ehmickybefore adoption27441fa
lines 18–19why, one step back18 }19Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 20–22why, one step back20 if (typeof stdio === 'string') {21 return stdio;22 }Add a logo (#201)ehmickybefore adoption27441fa
lines 23–27why, one step back2324 if (!Array.isArray(stdio)) {25 throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);26 }27Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 28–29why, one step back28 const length = Math.max(stdio.length, aliases.length);29 return Array.from({length}, (value, index) => stdio[index]);Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 30–31why, one step back30};31Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7
line 32why, one step back32// `ipc` is pushed unless it is already presentRequire Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 33why, one step back33export const normalizeStdioNode = options => {Upgrade dependenciesSindre Sorhusbefore adoption5d64878
line 34why, one step back34 const stdio = normalizeStdio(options);Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 35why, one step back35Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 36why, one step back36 if (stdio === 'ipc') {Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7
lines 37–38why, one step back37 return 'ipc';38 }Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 39why, one step back39Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
lines 40–41why, one step back40 if (stdio === undefined || typeof stdio === 'string') {41 return [stdio, stdio, stdio, 'ipc'];Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 42–43why, one step back42 }43Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
lines 44–45why, one step back44 if (stdio.includes('ipc')) {45 return stdio;Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 46–47why, one step back46 }47Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 48why, one step back48 return [...stdio, 'ipc'];Add a logo (#201)ehmickybefore adoption27441fa
line 49why, one step back49};