mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(ext/node): fix argv[1] in Worker (#20305)
This commit is contained in:
parent
bd034e360d
commit
fb7092fb43
2 changed files with 13 additions and 1 deletions
|
@ -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();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue