forked from yargs/yargs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display appropriate $0 for electron apps (yargs#1536)
Use process.defaultApp to detect built electron app
- Loading branch information
Showing
5 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function getProcessArgvBinIndex () { | ||
// Built Electron app: app argv1 argv2 ... argvn | ||
// (process.defaultApp is set to false by electron for built app for this purpose, | ||
// see https://github.com/electron/electron/issues/4690#issuecomment-217435222) | ||
if (process.defaultApp === false) return 0 | ||
// Default: node app.js argv1 argv2 ... argvn | ||
return 1 | ||
} | ||
|
||
function getProcessArgvWithoutBin () { | ||
return process.argv.slice(getProcessArgvBinIndex() + 1) | ||
} | ||
|
||
function getProcessArgvBin () { | ||
return process.argv[getProcessArgvBinIndex()] | ||
} | ||
|
||
module.exports = { | ||
getProcessArgvBin, | ||
getProcessArgvWithoutBin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters