nested-stdio.js
This file
Path
test/fixtures/nested-stdio.js
28 lines · 993 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1–28why, one step back1#!/usr/bin/env node2import process from 'node:process';3import {execa, execaSync} from '../../index.js';4import {parseStdioOption} from '../helpers/stdio.js';56const [stdioOption, fdNumber, isSyncString, file, ...commandArguments] = process.argv.slice(2);7const optionValue = parseStdioOption(stdioOption);8const isSync = isSyncString === 'true';9const stdio = ['ignore', 'inherit', 'inherit'];10stdio[fdNumber] = optionValue;11const execaMethod = isSync ? execaSync : execa;12const returnValue = execaMethod(file, [`${fdNumber}`, ...commandArguments], {stdio});1314const shouldPipe = Array.isArray(optionValue) && optionValue.includes('pipe');15const fdReturnValue = returnValue.stdio[fdNumber];16const hasPipe = fdReturnValue !== undefined && fdReturnValue !== null;1718if (shouldPipe && !hasPipe) {19 throw new Error(`subprocess.stdio[${fdNumber}] is null.`);20}2122if (!shouldPipe && hasPipe) {23 throw new Error(`subprocess.stdio[${fdNumber}] should be null.`);24}2526if (!isSync) {27 await returnValue;28}