blob: c29cc4f213ef0b6383e0e8f547ddedc5c0adce7c (
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
|
import { readableStreamToText } from "bun";
import { spawn } from "bun";
const proc = spawn({
cmd: ["ls", "-l"],
// Both of these forms work:
// as an array:
stdio: ["ignore", "pipe", "ignore"],
// You can also use "inherit" to inherit the parent's stdio.
// stdin: "inherit",
// You can pass a Bun.file to save it to a file:
// stdout: Bun.file("/tmp/stdout.txt"),
});
const result = await readableStreamToText(proc.stdout);
await proc.exitStatus;
console.log(result);
|