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 fileTake 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 back1import process, {platform} from 'node:process';Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
line 2why, one step back2import {noopReadable} from './stream.js';Refactor execa promise to use `async/await` (#653)ehmickybefore adoptiond69fd23
lines 3–4why, one step back34export const identity = value => value;Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 5why, one step back5Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 6–8why, one step back6export 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 back9 }10Improve `error.message` (#705)ehmickybefore adoption67b476b
line 11why, one step back11 const stdio = Array.from({length}).fill('pipe');Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 12why, one step back12 stdio[fdNumberOrName] = stdioOption;Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 13–16why, one step back13 return {stdio};14};1516export const fullStdio = getStdio(3, 'pipe');Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
line 17why, one step back17export const fullReadableStdio = () => getStdio(3, ['pipe', noopReadable()]);Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 18–19why, one step back1819export const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 20–21why, one step back2021export const prematureClose = {code: 'ERR_STREAM_PREMATURE_CLOSE'};Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 22–29why, one step back2223const 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 back3031export 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};