Skip to content
Myr

Fix using multiple `stdin` values (#661)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 61a1623 · Browse files · 3 files+26 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+26 added−13 removed

  • tests:+14 added−10 removed
  • other:+12 added−3 removed

3 files+26 added−13 removed

modified:lib/stdio/async.js+12 added-3 removed
modified:test/stdio/array.js+6 added-10 removed
1import {readFile, writeFile, rm} from 'node:fs/promises';2import process from 'node:process';3import {PassThrough} from 'node:stream';3import test from 'ava';4import tempfile from 'tempfile';5import {execa, execaSync} from '../../index.js';6import {getStdinOption, getStdoutOption, getStderrOption, getStdioOption} from '../helpers/stdio.js';7import {stringGenerator} from '../helpers/generator.js';8import {setFixtureDir} from '../helpers/fixtures-dir.js';910setFixtureDir();11
111 unmodified lines
123124test('stdio[*] default direction is output', testAmbiguousDirection, execa);125test('stdio[*] default direction is output - sync', testAmbiguousDirection, execaSync);126127const testAmbiguousMultiple = async (t, stdioOptions) => {127const testAmbiguousMultiple = async (t, fixtureName, getOptions) => {128 const filePath = tempfile();129 await writeFile(filePath, 'foobar');130 const {stdout} = await execa('stdin-fd3.js', getStdioOption([filePath, ...stdioOptions]));131 t.is(stdout, 'foobar');130 const {stdout} = await execa(fixtureName, getOptions([filePath, stringGenerator()]));131 t.is(stdout, 'foobarfoobar');132 await rm(filePath);133};134135test('stdio[*] ambiguous direction is influenced by other values like ReadableStream', testAmbiguousMultiple, [new ReadableStream()]);136test('stdio[*] ambiguous direction is influenced by other values like 0', testAmbiguousMultiple, [0]);137test('stdio[*] ambiguous direction is influenced by other values like process.stdin', testAmbiguousMultiple, [process.stdin]);138test('stdio[*] Duplex has an ambiguous direction like ReadableStream', testAmbiguousMultiple, [new PassThrough(), new ReadableStream()]);139test('stdio[*] Duplex has an ambiguous direction like 0', testAmbiguousMultiple, [new PassThrough(), 0]);140test('stdio[*] Duplex has an ambiguous direction like process.stdin', testAmbiguousMultiple, [new PassThrough(), process.stdin]);135test('stdin ambiguous direction is influenced by other values', testAmbiguousMultiple, 'stdin.js', getStdinOption);136test('stdio[*] ambiguous direction is influenced by other values', testAmbiguousMultiple, 'stdin-fd3.js', getStdioOption);137138const testRedirectInput = async (t, stdioOption, index, fixtureName) => {139 const {stdout} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), String(index), fixtureName], {input: 'foobar'});140 t.is(stdout, 'foobar');
125 unmodified lines
modified:test/stdio/iterable.js+8 added