diff --git a/dist/index.js b/dist/index.js index 6926123..6e77518 100644 --- a/dist/index.js +++ b/dist/index.js @@ -281,7 +281,10 @@ class Option { } const deno = typeof window !== 'undefined' && window.Deno; -const processArgs = deno ? ['deno'].concat(Deno.args) : process.argv; +const denoScriptPath = deno && typeof window !== 'undefined' && window.location.pathname; +// Adds deno executable and script path to processArgs as "compatibility" layer for node +// See https://github.com/cacjs/cac/issues/69 +const processArgs = deno ? ['deno', denoScriptPath].concat(Deno.args) : process.argv; const platformInfo = deno ? `${Deno.build.os}-${Deno.build.arch} deno-${Deno.version.deno}` : `${process.platform}-${process.arch} node-${process.version}`; diff --git a/mod.js b/mod.js index 645466e..64bb35e 100644 --- a/mod.js +++ b/mod.js @@ -704,7 +704,10 @@ class Option { } const deno = typeof window !== 'undefined' && window.Deno; -const processArgs = deno ? ['deno'].concat(Deno.args) : process.argv; +const denoScriptPath = deno && typeof window !== 'undefined' && window.location.pathname; +// Adds deno executable and script path to processArgs as "compatibility" layer for node +// See https://github.com/cacjs/cac/issues/69 +const processArgs = deno ? ['deno', denoScriptPath].concat(Deno.args) : process.argv; const platformInfo = deno ? `${Deno.build.os}-${Deno.build.arch} deno-${Deno.version.deno}` : `${process.platform}-${process.arch} node-${process.version}`; diff --git a/src/node.ts b/src/node.ts index 7cd4117..6f0824c 100644 --- a/src/node.ts +++ b/src/node.ts @@ -2,8 +2,14 @@ declare let window: any declare let Deno: any const deno = typeof window !== 'undefined' && window.Deno +const denoScriptPath = + deno && typeof window !== 'undefined' && window.location.pathname -export const processArgs = deno ? ['deno'].concat(Deno.args) : process.argv +// Adds deno executable and script path to processArgs as "compatibility" layer for node +// See https://github.com/cacjs/cac/issues/69 +export const processArgs = deno + ? ['deno', denoScriptPath].concat(Deno.args) + : process.argv export const platformInfo = deno ? `${Deno.build.os}-${Deno.build.arch} deno-${Deno.version.deno}`