diff options
author | Marvin Hagemeister <hello@marvinh.dev> | 2023-05-18 14:02:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 14:02:14 +0200 |
commit | 695b5de6cb0cb4a10b95cbae99f2f19e5621a9eb (patch) | |
tree | 5ba8cef3ffb4cf97798879da88da6bf5e8f76f24 /cli/tests | |
parent | 9dc3ae8523364b8df6b8e92346907d1020e80d33 (diff) |
fix(node): support passing parent stdio streams (#19171)
This is a bit bare bones but gets `npm-run-all` working. For full stdio
compatibility with node more work is needed which is probably better
done in follow up PRs.
Fixes #19159
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit_node/child_process_test.ts | 22 | ||||
-rw-r--r-- | cli/tests/unit_node/testdata/child_process_stdio.js | 15 |
2 files changed, 37 insertions, 0 deletions
diff --git a/cli/tests/unit_node/child_process_test.ts b/cli/tests/unit_node/child_process_test.ts index b40cfd9ff..e89fd7d79 100644 --- a/cli/tests/unit_node/child_process_test.ts +++ b/cli/tests/unit_node/child_process_test.ts @@ -577,3 +577,25 @@ Deno.test( assertStringIncludes(output, "typescript"); }, ); + +Deno.test( + "[node/child_process spawn] supports stdio array option", + async () => { + const cmdFinished = deferred(); + let output = ""; + const script = path.join( + path.dirname(path.fromFileUrl(import.meta.url)), + "testdata", + "child_process_stdio.js", + ); + const cp = spawn(Deno.execPath(), ["run", "-A", script]); + cp.stdout?.on("data", (data) => { + output += data; + }); + cp.on("close", () => cmdFinished.resolve()); + await cmdFinished; + + assertStringIncludes(output, "foo"); + assertStringIncludes(output, "close"); + }, +); diff --git a/cli/tests/unit_node/testdata/child_process_stdio.js b/cli/tests/unit_node/testdata/child_process_stdio.js new file mode 100644 index 000000000..399b890ed --- /dev/null +++ b/cli/tests/unit_node/testdata/child_process_stdio.js @@ -0,0 +1,15 @@ +import childProcess from "node:child_process"; +import process from "node:process"; +import * as path from "node:path"; + +const script = path.join( + path.dirname(path.fromFileUrl(import.meta.url)), + "node_modules", + "foo", + "index.js", +); + +const child = childProcess.spawn(process.execPath, [script], { + stdio: [process.stdin, process.stdout, process.stderr], +}); +child.on("close", () => console.log("close")); |