diff options
author | 2022-09-25 13:08:51 -0700 | |
---|---|---|
committer | 2022-09-25 13:08:51 -0700 | |
commit | a4d46fc7db7459e3e7e895d3013ffe65b0f0078c (patch) | |
tree | 8c6d78f3ccc127b16ff38fe098223bd9b69c2736 /examples/spawn.ts | |
parent | 7ce4a4e3d3f5f06a1258eefc49ce1da166e43886 (diff) | |
download | bun-jarred/subprocess.tar.gz bun-jarred/subprocess.tar.zst bun-jarred/subprocess.zip |
:sleepy:jarred/subprocess
Diffstat (limited to '')
-rw-r--r-- | examples/spawn.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/spawn.ts b/examples/spawn.ts new file mode 100644 index 000000000..c29cc4f21 --- /dev/null +++ b/examples/spawn.ts @@ -0,0 +1,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); |