cyb3r-downloader/src/main.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

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':
2017-09-10 20:42:21 +02:00
2017-08-14 17:20:34 +02:00
break;
case 'linux':
2017-09-10 20:42:21 +02:00
2017-08-14 17:20:34 +02:00
break;
default:
2017-09-10 20:42:21 +02:00
2017-08-14 17:20:34 +02:00
}
2017-08-13 23:47:09 +02:00
if (process.platform !== 'win32') {
return false;
}
2017-09-10 20:42:21 +02:00
const exeName = path.basename(process.execPath);
2017-08-13 23:47:09 +02:00
var squirrelCommand = process.argv[1];
console.log(squirrelCommand);
switch (squirrelCommand) {
2017-09-10 20:42:21 +02:00
case '--squirrel-updated':
2017-08-13 23:47:09 +02:00
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);
2017-09-10 20:42:21 +02:00
spawnUpdate(['--createShortcut', exeName]);
2017-08-13 23:47:09 +02:00
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);
2017-09-10 20:42:21 +02:00
spawnUpdate(['--removeShortcut', exeName]);
2017-08-13 23:47:09 +02:00
// 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;
}
})