diff options
author | 2022-10-12 14:43:24 -0700 | |
---|---|---|
committer | 2022-10-12 14:43:24 -0700 | |
commit | c5333ab59750831cba8bbe4058268716993e118a (patch) | |
tree | c9d01cf66e1291c9165fd858c45bcd688d7ac539 /test/bun.js/spawn.test.ts | |
parent | 75e8c4699c5a85bdf6dafb15506a59b4bfc79c43 (diff) | |
download | bun-c5333ab59750831cba8bbe4058268716993e118a.tar.gz bun-c5333ab59750831cba8bbe4058268716993e118a.tar.zst bun-c5333ab59750831cba8bbe4058268716993e118a.zip |
support array as first arg in `Bun.spawn`
Diffstat (limited to '')
-rw-r--r-- | test/bun.js/spawn.test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/bun.js/spawn.test.ts b/test/bun.js/spawn.test.ts index 6829791ce..9e4144024 100644 --- a/test/bun.js/spawn.test.ts +++ b/test/bun.js/spawn.test.ts @@ -11,6 +11,14 @@ for (let [gcTick, label] of [ describe("spawnSync", () => { const hugeString = "hello".repeat(10000).slice(); + it("as an array", () => { + const { stdout } = spawnSync(["echo", "hi"]); + + // stdout is a Buffer + const text = stdout.toString(); + expect(text).toBe("hi\n"); + }); + it("Uint8Array works as stdin", async () => { const { stdout, stderr } = spawnSync({ cmd: ["cat"], @@ -25,6 +33,30 @@ for (let [gcTick, label] of [ describe("spawn", () => { const hugeString = "hello".repeat(10000).slice(); + it("as an array", async () => { + const { stdout, exited } = spawn(["echo", "hello"], { + stdout: "pipe", + }); + gcTick(); + expect(await new Response(stdout).text()).toBe("hello\n"); + }); + + it("as an array with options object", async () => { + const { stdout } = spawn(["printenv", "FOO"], { + cwd: "/tmp", + env: { + ...process.env, + FOO: "bar", + }, + stdin: null, + stdout: "pipe", + stderr: "inherit", + }); + + const text = await new Response(stdout).text(); + expect(text).toBe("bar\n"); + }); + it("Uint8Array works as stdin", async () => { rmSync("/tmp/out.123.txt", { force: true }); gcTick(); |