From a8bfe709ba9cb68e529933ae86b91638e6836738 Mon Sep 17 00:00:00 2001 From: Kolja Lampe Date: Thu, 15 Sep 2016 16:51:36 +0200 Subject: [PATCH] Make sure our auto launch link is up do date --- src/main.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 08e4b462..677d0d82 100644 --- a/src/main.js +++ b/src/main.js @@ -17,17 +17,28 @@ process.on('uncaughtException', (error) => { if (process.platform === 'win32') { var cmd = process.argv[1]; + var AutoLaunch = require('auto-launch'); + var appLauncher = new AutoLaunch({ + name: 'Mattermost', + isHidden: true + }); if (cmd === '--squirrel-uninstall') { - var AutoLaunch = require('auto-launch'); - var appLauncher = new AutoLaunch({ - name: 'Mattermost', - isHidden: true - }); + // If we're uninstalling, make sure we also delete our auto launch registry key appLauncher.isEnabled().then(function(enabled) { if (enabled) appLauncher.disable(); }); } + else if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') { + // If we're updating and already have an registry entry for auto launch, make sure to update the path + appLauncher.isEnabled().then(function(enabled) { + if (enabled) { + return appLauncher.disable().then(function() { + return appLauncher.enable(); + }); + } + }); + } } require('electron-squirrel-startup');