mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 00:54:02 -05:00
feat(runtime/command): make stdin default to inherit for spawn() (#17334)
Closes #17230
This commit is contained in:
parent
654e177c91
commit
cadeaae045
3 changed files with 23 additions and 3 deletions
|
@ -83,6 +83,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(
|
Deno.test(
|
||||||
{ permissions: { run: true, read: true } },
|
{ permissions: { run: true, read: true } },
|
||||||
async function commandStdoutPiped() {
|
async function commandStdoutPiped() {
|
||||||
|
|
3
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
3
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -1640,7 +1640,8 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** How `stdin` of the spawned process should be handled.
|
/** 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";
|
stdin?: "piped" | "inherit" | "null";
|
||||||
/** How `stdout` of the spawned process should be handled.
|
/** How `stdout` of the spawned process should be handled.
|
||||||
*
|
*
|
||||||
|
|
|
@ -315,6 +315,7 @@
|
||||||
...(this.#options ?? {}),
|
...(this.#options ?? {}),
|
||||||
stdout: this.#options?.stdout ?? "inherit",
|
stdout: this.#options?.stdout ?? "inherit",
|
||||||
stderr: this.#options?.stderr ?? "inherit",
|
stderr: this.#options?.stderr ?? "inherit",
|
||||||
|
stdin: this.#options?.stdin ?? "inherit",
|
||||||
};
|
};
|
||||||
return spawnChild(this.#command, options);
|
return spawnChild(this.#command, options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue