Skip to content

Commit

Permalink
fix: $0 contains first arg in bundled electron apps (#1206)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phothiabea authored and bcoe committed Oct 6, 2018
1 parent 8e3a70f commit 567820b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions yargs.js
Expand Up @@ -42,12 +42,16 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}

self.$0 = process.argv
.slice(0, 2)
// ignore the node bin, specify this in your
// bin file with #!/usr/bin/env node
if (/\b(node|iojs|electron)(\.exe)?$/.test(process.argv[0])) {
self.$0 = process.argv.slice(1, 2)
} else {
self.$0 = process.argv.slice(0, 1)
}

self.$0 = self.$0
.map((x, i) => {
// ignore the node bin, specify this in your
// bin file with #!/usr/bin/env node
if (i === 0 && /\b(node|iojs)(\.exe)?$/.test(x)) return
const b = rebase(cwd, x)
return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x
})
Expand Down

0 comments on commit 567820b

Please sign in to comment.