Skip to content
Myr

nested-stdio.js

This file

Path

test/fixtures/nested-stdio.js

28 lines · 993 bytes · JavaScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

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

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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';

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

line 5why, one step back
5

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 6why, one step back
6const [stdioOption, fdNumber, isSyncString, file, ...commandArguments] = process.argv.slice(2);

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

lines 7–8why, one step back
7const optionValue = parseStdioOption(stdioOption);
8const isSync = isSyncString === 'true';

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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

line 11why, one step back
11const execaMethod = isSync ? execaSync : execa;

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 12why, one step back
12const returnValue = execaMethod(file, [`${fdNumber}`, ...commandArguments], {stdio});

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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;

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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.`);

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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.`);

Fix calling `.kill()` many times (#768)ehmickybefore adoptiondb95b51

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}