Skip to content

Commit 46c78dd

Browse files
committed
docs: add stdin example
1 parent 4b867a5 commit 46c78dd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ const { stdout } = await subprocess
8181
console.log(stdout) // => 1234567890
8282
```
8383

84+
or stdin:
85+
86+
```js
87+
const { Readable } = require('node:stream')
88+
89+
const subprocess = $('cat', { stdin: 'hello world' })
90+
Readable.from('hello world').pipe(subprocess.stdin)
91+
const {stdout} = await subprocess
92+
93+
console.log(stdout) // 'hello world'
94+
```
95+
8496
### JSON parsing
8597

8698
A CLI program commonly supports a way to return a JSON that makes it easy to connect with other programs.

0 commit comments

Comments
 (0)