summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2022-12-13 05:12:19 +0100
committerGitHub <noreply@github.com>2022-12-13 05:12:19 +0100
commita2ba573e77b63d2bcb5cba19fae09cebda2fc685 (patch)
treea39947b0a551c5017568b7628ca260b5c99c6213 /cli
parent8972ebc9cc33ef1df21c899c35006ea712f7f91f (diff)
fix: default to `"inherit"` for `Deno.Command#spawn()`'s `stdout` & `stderr` (#17025)
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/command_test.ts4
-rw-r--r--cli/tests/unit/flock_test.ts2
-rw-r--r--cli/tests/unit/http_test.ts28
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts6
4 files changed, 35 insertions, 5 deletions
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts
index d58053c84..2a0562c93 100644
--- a/cli/tests/unit/command_test.ts
+++ b/cli/tests/unit/command_test.ts
@@ -91,6 +91,7 @@ Deno.test(
"await Deno.stdout.write(new TextEncoder().encode('hello'))",
],
stderr: "null",
+ stdout: "piped",
});
const child = command.spawn();
@@ -124,6 +125,7 @@ Deno.test(
"await Deno.stderr.write(new TextEncoder().encode('hello'))",
],
stdout: "null",
+ stderr: "piped",
});
const child = command.spawn();
@@ -163,6 +165,8 @@ Deno.test(
"eval",
"Deno.stderr.write(new TextEncoder().encode('error\\n')); Deno.stdout.write(new TextEncoder().encode('output\\n'));",
],
+ stdout: "piped",
+ stderr: "piped",
});
const child = command.spawn();
await child.stdout.pipeTo(file.writable, {
diff --git a/cli/tests/unit/flock_test.ts b/cli/tests/unit/flock_test.ts
index be463bf12..20453a57a 100644
--- a/cli/tests/unit/flock_test.ts
+++ b/cli/tests/unit/flock_test.ts
@@ -151,6 +151,8 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
const process = new Deno.Command(Deno.execPath(), {
args: ["eval", "--unstable", scriptText],
stdin: "piped",
+ stdout: "piped",
+ stderr: "null",
}).spawn();
const waitSignal = async () => {
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 0c17c7277..347551362 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -1383,6 +1383,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1430,7 +1431,11 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
+ const proc = new Deno.Command("curl", {
+ args,
+ stderr: "null",
+ stdout: "piped",
+ }).spawn();
const status = await proc.status;
assert(status.success);
const stdout = proc.stdout
@@ -1488,6 +1493,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout).toLocaleLowerCase();
@@ -1543,6 +1549,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1595,6 +1602,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1651,6 +1659,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1709,6 +1718,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1767,6 +1777,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1822,6 +1833,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1883,6 +1895,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -1939,7 +1952,11 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
+ const proc = new Deno.Command("curl", {
+ args,
+ stderr: "null",
+ stdout: "piped",
+ }).spawn();
const status = await proc.status;
assert(status.success);
const stdout = proc.stdout
@@ -2007,6 +2024,7 @@ Deno.test({
const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
+ stdout: "piped",
}).output();
assert(success);
const output = decoder.decode(stdout);
@@ -2569,7 +2587,11 @@ Deno.test({
"Accept-Encoding: gzip, deflate, br",
"--no-buffer",
];
- const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
+ const proc = new Deno.Command("curl", {
+ args,
+ stderr: "null",
+ stdout: "piped",
+ }).spawn();
const stdout = proc.stdout
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream());
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index d3bf8a91b..d0f1e204a 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -1456,11 +1456,13 @@ declare namespace Deno {
stdin?: "piped" | "inherit" | "null";
/** How `stdout` of the spawned process should be handled.
*
- * Defaults to `"piped"`. */
+ * Defaults to `"piped"` for `output` & `outputSync`,
+ * and `"inherit"` for `spawn`. */
stdout?: "piped" | "inherit" | "null";
/** How `stderr` of the spawned process should be handled.
*
- * Defaults to "piped". */
+ * Defaults to "piped" for `output` & `outputSync`,
+ * and `"inherit"` for `spawn`. */
stderr?: "piped" | "inherit" | "null";
/** Skips quoting and escaping of the arguments on windows. This option