From a4d46fc7db7459e3e7e895d3013ffe65b0f0078c Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Sep 2022 13:08:51 -0700 Subject: :sleepy: --- examples/spawn.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/spawn.ts (limited to 'examples/spawn.ts') 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); -- cgit v1.2.3