2017-08-13 23:47:09 +02:00
|
|
|
var app = require('./index');
|
|
|
|
|
|
|
|
var handleStartupEvent = function() {
|
2017-08-14 17:20:34 +02:00
|
|
|
console.log(process.platform);
|
|
|
|
switch (process.platform) {
|
|
|
|
case 'win32':
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'linux':
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
2017-08-13 23:47:09 +02:00
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var squirrelCommand = process.argv[1];
|
|
|
|
console.log(squirrelCommand);
|
|
|
|
switch (squirrelCommand) {
|
|
|
|
case '--squirrel-install':
|
|
|
|
target = path.basename(process.execPath);
|
|
|
|
updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
|
|
|
|
var createShortcut = updateDotExe + ' --createShortcut=' + target + ' --shortcut-locations=Desktop,StartMenu' ;
|
|
|
|
console.log (createShortcut);
|
|
|
|
exec(createShortcut);
|
|
|
|
// Always quit when done
|
|
|
|
app.quit();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case '--squirrel-uninstall':
|
|
|
|
// Undo anything you did in the --squirrel-install and
|
|
|
|
// --squirrel-updated handlers
|
|
|
|
target = path.basename(process.execPath);
|
|
|
|
updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
|
|
|
|
var createShortcut = updateDotExe + ' --removeShortcut=' + target ;
|
|
|
|
console.log (createShortcut);
|
|
|
|
exec(createShortcut);
|
|
|
|
// Always quit when done
|
|
|
|
app.quit();
|
|
|
|
return true;
|
|
|
|
case '--squirrel-obsolete':
|
|
|
|
// This is called on the outgoing version of your app before
|
|
|
|
// we update to the new version - it's the opposite of
|
|
|
|
// --squirrel-updated
|
|
|
|
app.quit();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
(function(){
|
|
|
|
if (handleStartupEvent()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|