Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 10c73dc point at it.

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

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

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

line 2why, one step back
2

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

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

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

line 4why, one step back
4

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 5why, one step back
5export const normalizeStdio = options => {

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

line 6why, one step back
6 if (!options) {

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

lines 7–9why, one step back
7 return;
8 }9

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

line 10why, one step back
10 const {stdio} = options;

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

lines 11–12why, one step back
11
12 if (stdio === undefined) {

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

line 13why, one step back
13 return aliases.map(alias => options[alias]);

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

lines 14–15why, one step back
14 }
15

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

line 16why, one step back
16 if (hasAlias(options)) {

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

line 17why, one step back
17 throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

lines 18–19why, one step back
18 }
19

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

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

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

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

Refactor `stdio` option (#302)ehmickybefore adoption977ad1d

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

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

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

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 33why, one step back
33export const normalizeStdioNode = options => {

Upgrade dependenciesSindre Sorhusbefore adoption5d64878

line 34why, one step back
34 const stdio = normalizeStdio(options);

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

line 35why, one step back
35

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

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

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

lines 37–38why, one step back
37 return 'ipc';
38 }

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

line 39why, one step back
39

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

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

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

lines 42–43why, one step back
42 }
43

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

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

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

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

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

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

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

line 49why, one step back
49};