Clean up multi instance code.

pull/36/head
Mikunj 7 years ago
parent bd0ce981dd
commit e2a48b8373

@ -1,5 +1,5 @@
{
"storageProfile": "development2",
"storageProfile": "development1",
"disableAutoUpdate": true,
"openDevTools": true
}

@ -56,6 +56,7 @@ const importMode =
process.argv.some(arg => arg === '--import') || config.get('import');
const development = config.environment === 'development';
const appInstance = config.util.getEnv('NODE_APP_INSTANCE') || 0;
// We generally want to pull in our own modules after this point, after the user
// data directory has been set.
@ -96,7 +97,7 @@ function showWindow() {
}
}
if (!process.mas && !development) {
if (!process.mas) {
console.log('making app single instance');
const shouldQuit = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window
@ -110,7 +111,7 @@ if (!process.mas && !development) {
return true;
});
if (shouldQuit) {
if (appInstance === 0 && shouldQuit) {
console.log('quitting; we are the second instance');
app.exit();
}

@ -13,6 +13,7 @@
"scripts": {
"postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider",
"start": "electron .",
"start-multi": "NODE_APP_INSTANCE=1 electron .",
"grunt": "grunt",
"icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build",
"generate": "yarn icon-gen && yarn grunt",

Loading…
Cancel
Save