Skip to content
Myr

nested-stdio.js

This file

Path

test/fixtures/nested-stdio.js

28 lines · 969 bytes · JavaScript

Last changed by

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

History of this file

Take it

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

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

lines 1–2why, one step back
1#!/usr/bin/env node
2import process from 'node:process';

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 3–4why, one step back
3import {execa, execaSync} from '../../index.js';
4import {parseStdioOption} from '../helpers/stdio.js';

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

line 5why, one step back
5

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 6–8why, one step back
6const [stdioOption, fdNumber, isSyncString, file, ...args] = process.argv.slice(2);
7const optionValue = parseStdioOption(stdioOption);8const isSync = isSyncString === 'true';

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

line 9why, one step back
9const stdio = ['ignore', 'inherit', 'inherit'];

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 10why, one step back
10stdio[fdNumber] = optionValue;

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 11–12why, one step back
11const execaMethod = isSync ? execaSync : execa;
12const returnValue = execaMethod(file, [`${fdNumber}`, ...args], {stdio});

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

lines 13–14why, one step back
13
14const shouldPipe = Array.isArray(optionValue) && optionValue.includes('pipe');

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 15–16why, one step back
15const fdReturnValue = returnValue.stdio[fdNumber];
16const hasPipe = fdReturnValue !== undefined && fdReturnValue !== null;

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

lines 17–18why, one step back
17
18if (shouldPipe && !hasPipe) {

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 19why, one step back
19 throw new Error(`subprocess.stdio[${fdNumber}] is null.`);

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

lines 20–22why, one step back
20}
2122if (!shouldPipe && hasPipe) {

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 23why, one step back
23 throw new Error(`subprocess.stdio[${fdNumber}] should be null.`);

Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23

lines 24–25why, one step back
24}
25

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 26–28why, one step back
26if (!isSync) {
27 await returnValue;28}