-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use process.defaultApp to detect built electron app (#1536)
* Use process.defaultApp to detect built electron app To remove only the first element of process.argv * add a comment to precise process.defaultApp is set by electron
- 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