summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/node/polyfills/internal/child_process.ts6
-rw-r--r--tests/unit_node/child_process_test.ts12
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts
index 62de6a098..5a9212618 100644
--- a/ext/node/polyfills/internal/child_process.ts
+++ b/ext/node/polyfills/internal/child_process.ts
@@ -275,7 +275,11 @@ export class ChildProcess extends EventEmitter {
});
})();
} catch (err) {
- this.#_handleError(err);
+ let e = err;
+ if (e instanceof Deno.errors.NotFound) {
+ e = _createSpawnSyncError("ENOENT", command, args);
+ }
+ this.#_handleError(e);
}
}
diff --git a/tests/unit_node/child_process_test.ts b/tests/unit_node/child_process_test.ts
index 9c6fed9e4..85bb6d3b0 100644
--- a/tests/unit_node/child_process_test.ts
+++ b/tests/unit_node/child_process_test.ts
@@ -771,3 +771,15 @@ Deno.test(async function execFileWithUndefinedTimeout() {
);
await promise;
});
+
+Deno.test(async function spawnCommandNotFoundErrno() {
+ const { promise, resolve } = Promise.withResolvers<void>();
+ const cp = CP.spawn("no-such-command");
+ cp.on("error", (err) => {
+ const errno = Deno.build.os === "windows" ? -4058 : -2;
+ // @ts-ignore: errno missing from typings
+ assertEquals(err.errno, errno);
+ resolve();
+ });
+ await promise;
+});