Skip to content
Myr

Do not read streams more than once (#330)

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

authored by ehmicky · committed by Sindre Sorhus · parent 7d51047 · Browse files · 3 files+11 added−1 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+11 added−1 removed

  • tests:+6 added−0 removed
  • other:+5 added−1 removed

3 files+11 added−1 removed

modified:test/test.js+6 added
136 unmodified lines
137 });138 t.true(failed);139});140141test('do not try to consume streams twice', async t => {142 const cp = execa('noop', ['foo']);143 t.is((await cp).stdout, 'foo');144 t.is((await cp).stdout, 'foo');145});146147test('use relative path with \'..\' chars', async t => {148 const pathViaParentDir = path.join('..', path.basename(path.dirname(__dirname)), 'test', 'fixtures', 'noop');149 const {stdout} = await execa(pathViaParentDir, ['foo']);150 t.is(stdout, 'foo');
68 unmodified lines
modified:index.js+4 added-1 removed
2 unmodified lines
3const childProcess = require('child_process');4const crossSpawn = require('cross-spawn');5const stripFinalNewline = require('strip-final-newline');6const npmRunPath = require('npm-run-path');7const onetime = require('onetime');8const makeError = require('./lib/error');9const normalizeStdio = require('./lib/stdio');10const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = require('./lib/kill');11const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = require('./lib/stream.js');
132 unmodified lines
144 killed: false145 };146 };147148 const handlePromiseOnce = onetime(handlePromise);149150 crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);151152 handleInput(spawned, parsed.options.input);153154 spawned.all = makeAllStream(spawned);155153 return mergePromise(spawned, handlePromise);156 return mergePromise(spawned, handlePromiseOnce);157};158159module.exports = execa;160
94 unmodified lines
modified:package.json+1 added