Skip to content

Commit

Permalink
fix(deno): Fix deno argv handling (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Rodrigues <[email protected]>
  • Loading branch information
drawveloper and Guilherme Rodrigues authored Mar 20, 2020
1 parent a3cb4e5 commit f607e96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
5 changes: 4 additions & 1 deletion mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
8 changes: 7 additions & 1 deletion src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down

0 comments on commit f607e96

Please sign in to comment.