diff options
author | 2022-09-25 13:08:51 -0700 | |
---|---|---|
committer | 2022-09-25 13:14:23 -0700 | |
commit | 7cc772cd391de428a9f9010e40abf0f8d3ba625a (patch) | |
tree | 4d5d86b6b86686ee3ca8443bda6d15dd75fa3dc9 /examples/spawn.ts | |
parent | 7ae73fad68e01e63d217b931110e5698ea97a899 (diff) | |
download | bun-7cc772cd391de428a9f9010e40abf0f8d3ba625a.tar.gz bun-7cc772cd391de428a9f9010e40abf0f8d3ba625a.tar.zst bun-7cc772cd391de428a9f9010e40abf0f8d3ba625a.zip |
:sleepy:
Diffstat (limited to 'examples/spawn.ts')
-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); |