From e2a48b8373f676b42f1b5becec196d6ace26193a Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 14 Nov 2018 09:19:02 +1100 Subject: [PATCH] Clean up multi instance code. --- config/{development2.json => development-1.json} | 2 +- main.js | 5 +++-- package.json | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) rename config/{development2.json => development-1.json} (60%) diff --git a/config/development2.json b/config/development-1.json similarity index 60% rename from config/development2.json rename to config/development-1.json index c1fae0625..9099ce326 100644 --- a/config/development2.json +++ b/config/development-1.json @@ -1,5 +1,5 @@ { - "storageProfile": "development2", + "storageProfile": "development1", "disableAutoUpdate": true, "openDevTools": true } diff --git a/main.js b/main.js index e000e2f55..220b36055 100644 --- a/main.js +++ b/main.js @@ -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(); } diff --git a/package.json b/package.json index de82011e0..2f82b9eea 100644 --- a/package.json +++ b/package.json @@ -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",