Skip to content

Commit

Permalink
Add tips about redirecting streams to files (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed Jun 17, 2019
1 parent eefe05f commit 11b32af
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ Let's say you want to show the output of a child process in real-time while also
const execa = require('execa');

const subprocess = execa('echo', ['foo']);

subprocess.stdout.pipe(process.stdout);

(async () => {
Expand All @@ -451,6 +450,24 @@ subprocess.stdout.pipe(process.stdout);
})();
```

### Redirect output to a file

```js
const execa = require('execa');

const subprocess = execa('echo', ['foo'])
subprocess.stdout.pipe(fs.createWriteStream('stdout.txt'))
```

### Redirect input from a file

```js
const execa = require('execa');

const subprocess = execa('cat')
fs.createReadStream('stdin.txt').pipe(subprocess.stdin)
```


## Related

Expand Down

0 comments on commit 11b32af

Please sign in to comment.