blob: e73fe59a0eb6adab0b13d87cccac6f6401360090 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
---
name: Read stdout from a child process
---
When using [`Bun.spawn()`](/docs/api/spawn), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
```ts
const proc = Bun.spawn(["echo", "hello"]);
const output = await new Response(proc.stdout).text();
output; // => "hello"
```
---
To instead pipe the `stdout` of the child process to `stdout` of the parent process, set "inherit".
```ts
const proc = Bun.spawn(["echo", "hello"], {
stdout: "inherit",
});
```
---
See [Docs > API > Child processes](/docs/api/spawn) for complete documentation.
|