Reputation: 7802
What is a the difference between Electron flags process.defaultApp
and app.isPackaged
? Both are used to distinguish dev and production environment. My observation is that Boolean(process.defaultApp) == !app.isPackaged
always. Are there any cases, when both are true
or both are false
?
From doc and code:
A Boolean. When app is started by being passed as parameter to the default app, this property is true in the main process, otherwise it is undefined.
A Boolean property that returns true if the app is packaged, false otherwise. For many apps, this property can be used to distinguish development and production environments.
From the code - app.isPackaged
is set when exec file is not electron
or electron.exe
.
Note: I know a minor difference is that process.defaultApp
may be used in the main process only.
Upvotes: 5
Views: 3367
Reputation: 71
Both can yield the same result, but some extra care has to be taken for the process.defaultApp
property:
undefined
(by using the !
operator for instance)var isPackaged = !process.defaultApp;
is equivalent to:
var isPackaged = require('electron').app.isPackaged;
var isPackaged = !require('electron').remote.process.defaultApp;
is equivalent to:
var isPackaged = require('electron').remote.app.isPackaged;
Edit:
Some extra information, although not 100% crystal clear, about why the app.isPackaged
property had to be added can be found in the related pull request's conversation: add app.isPackaged #12656
Upvotes: 7