summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.unstable.d.ts6
-rw-r--r--cli/tests/unit/spawn_test.ts (renamed from cli/tests/unit/command_test.ts)26
2 files changed, 32 insertions, 0 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index fbbe165f9..ca437bf44 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -1346,6 +1346,12 @@ declare namespace Deno {
uid?: number;
/** Similar to `uid`, but sets the group ID of the child process. */
gid?: number;
+ /**
+ * An AbortSignal that allows closing the process using the corresponding
+ * AbortController by sending the process a SIGTERM signal.
+ * Not Supported by execSync.
+ */
+ signal?: AbortSignal;
/** Defaults to "null". */
stdin?: "piped" | "inherit" | "null";
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/spawn_test.ts
index 4b3d5bd11..c2c7fdbac 100644
--- a/cli/tests/unit/command_test.ts
+++ b/cli/tests/unit/spawn_test.ts
@@ -249,6 +249,32 @@ Deno.test(
);
Deno.test(
+ { permissions: { run: true, read: true } },
+ async function spawnAbort() {
+ const ac = new AbortController();
+ const child = Deno.spawnChild(Deno.execPath(), {
+ args: [
+ "eval",
+ "setTimeout(console.log, 1e8)",
+ ],
+ signal: ac.signal,
+ stdout: "null",
+ stderr: "null",
+ });
+ queueMicrotask(() => ac.abort());
+ const status = await child.status;
+ assertEquals(status.success, false);
+ if (Deno.build.os === "windows") {
+ assertEquals(status.code, 1);
+ assertEquals(status.signal, null);
+ } else {
+ assertEquals(status.success, false);
+ assertEquals(status.code, 143);
+ }
+ },
+);
+
+Deno.test(
{ permissions: { read: true, run: false } },
async function spawnPermissions() {
await assertRejects(async () => {