Skip to content
Myr

Fix documentation about piping from stdin (#536)

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

authored by ehmicky · committed by GitHub · parent 7c808f1 · Browse files · 2 files+15 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

2 files+15 added−13 removed

  • other:+15 added−13 removed

2 files+15 added−13 removed

modified:docs/scripts.md+1 added-1 removed
633 unmodified lines
634```635636```js637// Execa638await $`cat`.pipeStdin('file.txt');638await $({input: fs.createReadStream('file.txt')})`cat`639```640641### Silent stderr642
14 unmodified lines
modified:readme.md+14 added-12 removed
124 unmodified lines
125```js126import {execa} from 'execa';127128// Similar to `echo unicorns > stdout.txt` in Bash129await execa('echo', ['unicorns']).pipeStdout('stdout.txt')129await execa('echo', ['unicorns']).pipeStdout('stdout.txt');130131// Similar to `echo unicorns 2> stdout.txt` in Bash132await execa('echo', ['unicorns']).pipeStderr('stderr.txt')132await execa('echo', ['unicorns']).pipeStderr('stderr.txt');133134// Similar to `echo unicorns &> stdout.txt` in Bash135await execa('echo', ['unicorns'], {all:true}).pipeAll('all.txt')135await execa('echo', ['unicorns'], {all:true}).pipeAll('all.txt');136```137138### Redirect input from a file139140```js141import {execa} from 'execa';142143// Similar to `cat < stdin.txt` in Bash144const {stdout} = await execa('cat', {input:fs.createReadStream('stdin.txt')});145console.log(stdout);146//=> 'unicorns'147```148149### Save and pipe output from a child process150151```js152import {execa} from 'execa';
622 unmodified lines
775776console.log(await pRetry(run, {retries: 5}));777```778768### Redirect input from a file769770```js771import {execa} from 'execa';772773const subprocess = execa('cat')774fs.createReadStream('stdin.txt').pipe(subprocess.stdin)775```776779### Execute the current package's binary780781```js782import {getBinPathSync} from 'get-bin-path';
29 unmodified lines