From b613a742f53bb8498c42dec4fb872faf5a6d0011 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Dec 2016 14:17:22 +0000 Subject: [PATCH] Forgot to re-add squirrelhooks --- electron/src/squirrelhooks.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 electron/src/squirrelhooks.js diff --git a/electron/src/squirrelhooks.js b/electron/src/squirrelhooks.js new file mode 100644 index 0000000000..10fb8d9ec5 --- /dev/null +++ b/electron/src/squirrelhooks.js @@ -0,0 +1,30 @@ +const path = require('path'); +const spawn = require('child_process').spawn; +const app = require('electron').app; + +function run_update_exe(args, done) { + const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe'); + spawn(updateExe, args, { + detached: true + }).on('close', done); +}; + +function check_squirrel_hooks() { + if (process.platform != 'win32') return false; + + const cmd = process.argv[1]; + const target = path.basename(process.execPath); + if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') { + run_update_exe(['--createShortcut=' + target + ''], app.quit); + return true; + } else if (cmd === '--squirrel-uninstall') { + run_update_exe(['--removeShortcut=' + target + ''], app.quit); + return true; + } else if (cmd === '--squirrel-obsolete') { + app.quit(); + return true; + } + return false; +} + +module.exports = check_squirrel_hooks;