stdio.js
This file
Path
lib/stdio.js
52 lines · 1.1 KiB · JavaScript
Last changed by
Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
History of this fileTake it
Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 1why, one step back1'use strict';Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
line 2why, one step back2const aliases = ['stdin', 'stdout', 'stderr'];Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 3why, one step back3Do not allow `stdin: 0` combined with `stdio` (#301)ehmickybefore adoption2c65870
line 4why, one step back4const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 5why, one step back5Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 6why, one step back6const normalizeStdio = opts => {Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 7why, one step back7 if (!opts) {Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
line 8why, one step back8 return;Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 9–10why, one step back9 }10Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 11–14why, one step back11 const {stdio} = opts;1213 if (stdio === undefined) {14 return aliases.map(alias => opts[alias]);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 15–16why, one step back15 }16Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 17–18why, one step back17 if (hasAlias(opts)) {18 throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 19–20why, one step back19 }20Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 21–23why, one step back21 if (typeof stdio === 'string') {22 return stdio;23 }Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 24–28why, one step back2425 if (!Array.isArray(stdio)) {26 throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);27 }28Refactor `stdio` option (#302)ehmickybefore adoption977ad1d
lines 29–30why, one step back29 const length = Math.max(stdio.length, aliases.length);30 return Array.from({length}, (value, index) => stdio[index]);Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 31–32why, one step back31};32Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 33why, one step back33module.exports = normalizeStdio;Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 34why, one step back34Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7
line 35why, one step back35// `ipc` is pushed unless it is already presentAdd `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 36why, one step back36module.exports.node = opts => {Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 37why, one step back37 const stdio = normalizeStdio(opts);Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 38why, one step back38Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 39why, one step back39 if (stdio === 'ipc') {Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7
lines 40–41why, one step back40 return 'ipc';41 }Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 42why, one step back42Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
lines 43–44why, one step back43 if (stdio === undefined || typeof stdio === 'string') {44 return [stdio, stdio, stdio, 'ipc'];Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 45–46why, one step back45 }46Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
lines 47–48why, one step back47 if (stdio.includes('ipc')) {48 return stdio;Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 49–50why, one step back49 }50Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f
line 51why, one step back51 return [...stdio, 'ipc'];Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 52why, one step back52};