1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/node): fix argv[1] in Worker (#20305)

This commit is contained in:
Yoshiya Hinosawa 2023-08-29 12:18:25 +09:00 committed by GitHub
parent bd034e360d
commit fb7092fb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -774,3 +774,15 @@ Deno.test({
assertEquals(process.title, "deno");
},
});
Deno.test({
name: "process.argv[1] in Worker",
async fn() {
const worker = new Worker(
`data:text/javascript,import process from "node:process";console.log(process.argv[1]);`,
{ type: "module" },
);
await delay(10);
worker.terminate();
},
});

View file

@ -873,7 +873,7 @@ internals.__bootstrapNodeProcess = function (
// Overwrites the 2st item with getter.
Object.defineProperty(argv, "1", {
get: () => {
if (Deno.mainModule.startsWith("file:")) {
if (Deno.mainModule?.startsWith("file:")) {
return pathFromURL(new URL(Deno.mainModule));
} else {
return join(Deno.cwd(), "$deno$node.js");