mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
24 lines
492 B
TypeScript
24 lines
492 B
TypeScript
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.exited();
|
|
|
|
console.log(result);
|