Skip to content
Myr

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 file

Take it

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 1why, one step back
1'use strict';

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

line 2why, one step back
2const aliases = ['stdin', 'stdout', 'stderr'];

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 3why, one step back
3

Do not allow `stdin: 0` combined with `stdio` (#301)ehmickybefore adoption2c65870

line 4why, one step back
4const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined);

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 5why, one step back
5

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

line 6why, one step back
6const normalizeStdio = opts => {

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 7why, one step back
7 if (!opts) {

Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504

line 8why, one step back
8 return;

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 9–10why, one step back
9 }
10

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

lines 11–14why, one step back
11 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 back
15 }
16

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

lines 17–18why, one step back
17 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 back
19 }
20

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

lines 21–23why, one step back
21 if (typeof stdio === 'string') {
22 return stdio;23 }

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 24–28why, one step back
24
25 if (!Array.isArray(stdio)) {26 throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);27 }28

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

lines 29–30why, one step back
29 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 back
31};
32

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

line 33why, one step back
33module.exports = normalizeStdio;

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 34why, one step back
34

Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7

line 35why, one step back
35// `ipc` is pushed unless it is already present

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 36why, one step back
36module.exports.node = opts => {

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

line 37why, one step back
37 const stdio = normalizeStdio(opts);

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 38why, one step back
38

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

line 39why, one step back
39 if (stdio === 'ipc') {

Refactor `stdio` option for `execa.node()` (#303)ehmickybefore adoption825f8a7

lines 40–41why, one step back
40 return 'ipc';
41 }

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 42why, one step back
42

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

lines 43–44why, one step back
43 if (stdio === undefined || typeof stdio === 'string') {
44 return [stdio, stdio, stdio, 'ipc'];

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 45–46why, one step back
45 }
46

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

lines 47–48why, one step back
47 if (stdio.includes('ipc')) {
48 return stdio;

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 49–50why, one step back
49 }
50

Rename variables in `stdio` file (#306)ehmickybefore adoptiona9fa13f

line 51why, one step back
51 return [...stdio, 'ipc'];

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 52why, one step back
52};