diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-01-24 15:03:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 15:03:46 +0100 |
commit | cadeaae045d2489fe125286b8c2c641c6d973c3f (patch) | |
tree | ff98b976cfa25fe3d85201d01a290334a0472f12 | |
parent | 654e177c919babe4eef4c1c9545ef267b23884e6 (diff) |
feat(runtime/command): make stdin default to inherit for spawn() (#17334)
Closes #17230
-rw-r--r-- | cli/tests/unit/command_test.ts | 18 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 7 | ||||
-rw-r--r-- | runtime/js/40_spawn.js | 1 |
3 files changed, 23 insertions, 3 deletions
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts index e7f940535..b9fa8295b 100644 --- a/cli/tests/unit/command_test.ts +++ b/cli/tests/unit/command_test.ts @@ -85,6 +85,24 @@ Deno.test( Deno.test( { permissions: { run: true, read: true } }, + async function commandStdinPiped() { + const command = new Deno.Command(Deno.execPath(), { + args: ["info"], + stdout: "null", + stderr: "null", + }); + const child = command.spawn(); + + assertThrows(() => child.stdin, TypeError, "stdin is not piped"); + assertThrows(() => child.stdout, TypeError, "stdout is not piped"); + assertThrows(() => child.stderr, TypeError, "stderr is not piped"); + + await child.status; + }, +); + +Deno.test( + { permissions: { run: true, read: true } }, async function commandStdoutPiped() { const command = new Deno.Command(Deno.execPath(), { args: [ diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 7ca089108..12186c0b3 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -95,9 +95,9 @@ declare namespace Deno { type NativeVoidType = "void"; /** **UNSTABLE**: New API, yet to be vetted. - * + * * The native struct type for interfacing with foreign functions. - * + * */ type NativeStructType = { readonly struct: readonly NativeType[] }; @@ -1640,7 +1640,8 @@ declare namespace Deno { /** How `stdin` of the spawned process should be handled. * - * Defaults to `"null"`. */ + * Defaults to `"inherit"` for `output` & `outputSync`, + * and `"inherit"` for `spawn`. */ stdin?: "piped" | "inherit" | "null"; /** How `stdout` of the spawned process should be handled. * diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js index 9c1d96a28..ecbab52ad 100644 --- a/runtime/js/40_spawn.js +++ b/runtime/js/40_spawn.js @@ -315,6 +315,7 @@ ...(this.#options ?? {}), stdout: this.#options?.stdout ?? "inherit", stderr: this.#options?.stderr ?? "inherit", + stdin: this.#options?.stdin ?? "inherit", }; return spawnChild(this.#command, options); } |