Skip to content
Myr

stdio.js

This file

Path

test/helpers/stdio.js

42 lines · 1.2 KiB · 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.

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

line 1why, one step back
1import process, {platform} from 'node:process';

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

line 2why, one step back
2import {noopReadable} from './stream.js';

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

lines 3–4why, one step back
3
4export const identity = value => value;

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 5why, one step back
5

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

lines 6–8why, one step back
6export const getStdio = (fdNumberOrName, stdioOption, length = 3) => {
7 if (typeof fdNumberOrName === 'string') {8 return {[fdNumberOrName]: stdioOption};

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

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

Improve `error.message` (#705)ehmickybefore adoption67b476b

line 11why, one step back
11 const stdio = Array.from({length}).fill('pipe');

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

line 12why, one step back
12 stdio[fdNumberOrName] = stdioOption;

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 13–16why, one step back
13 return {stdio};
14};1516export const fullStdio = getStdio(3, 'pipe');

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

line 17why, one step back
17export const fullReadableStdio = () => getStdio(3, ['pipe', noopReadable()]);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 18–19why, one step back
18
19export const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 20–21why, one step back
20
21export const prematureClose = {code: 'ERR_STREAM_PREMATURE_CLOSE'};

Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9

lines 22–29why, one step back
22
23const isWindows = platform === 'win32';2425export const assertEpipe = (t, stderr, fdNumber = 1) => {26 if (fdNumber === 1 && !isWindows) {27 t.true(stderr.includes('EPIPE'));28 }29};

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

lines 30–42why, one step back
30
31export const parseStdioOption = stdioOption => {32 const optionValue = JSON.parse(stdioOption);33 if (typeof optionValue === 'string' && optionValue in process) {34 return process[optionValue];35 }3637 if (Array.isArray(optionValue) && typeof optionValue[0] === 'string' && optionValue[0] in process) {38 return [process[optionValue[0]], ...optionValue.slice(1)];39 }4041 return optionValue;42};