* Revert79d164309f
as it seems to break shortcuts altogether * Update electron-builder (and add the squirrel windows package that the newer version now requires: it's been split out). This uses a newer version of squirrel which has some fixes for shortcuts. I'm unsure exactly what was going wrong originally in https://github.com/vector-im/riot-web/issues/2775 but #79d1643
seems to break shortcut creation as far as I can see.
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const spawn = require('child_process').spawn;
|
|
const app = require('electron').app;
|
|
|
|
function run_update_exe(args, done) {
|
|
// Invokes Squirrel's Update.exe which will do things for us like create shortcuts
|
|
// Note that there's an Update.exe in the app-x.x.x directory and one in the parent
|
|
// directory: we need to run the one in the parent directory, because it discovers
|
|
// information about the app by inspecting the directory it's run from.
|
|
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
|
|
console.log('Spawning `%s` with args `%s`', updateExe, args);
|
|
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;
|