2019-05-10 16:24:22 +00:00
|
|
|
import path from 'path';
|
|
|
|
import { spawn } from 'child_process';
|
|
|
|
import { app } from 'electron';
|
|
|
|
|
|
|
|
function run(args, done) {
|
|
|
|
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
|
2019-05-10 19:20:07 +00:00
|
|
|
spawn(updateExe, args, { detached: true }).on('close', done);
|
2019-05-10 16:24:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 16:30:20 +00:00
|
|
|
export function checkIfRestartNeeded() {
|
2019-05-15 22:34:12 +00:00
|
|
|
if (process.platform !== 'win32') {
|
2019-05-10 19:20:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-05-10 16:24:22 +00:00
|
|
|
|
2019-05-10 19:20:07 +00:00
|
|
|
const cmd = process.argv[1];
|
|
|
|
console.log('processing squirrel command `%s`', cmd);
|
|
|
|
const target = path.basename(process.execPath);
|
2019-05-10 16:24:22 +00:00
|
|
|
|
2019-05-10 19:20:07 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case '--squirrel-install':
|
|
|
|
run(['--createShortcut=' + target + ''], app.quit);
|
2019-05-10 16:24:22 +00:00
|
|
|
return true;
|
2019-05-10 19:20:07 +00:00
|
|
|
case '--squirrel-uninstall':
|
2019-05-10 16:24:22 +00:00
|
|
|
run(['--removeShortcut=' + target + ''], app.quit);
|
|
|
|
return true;
|
2019-05-10 19:20:07 +00:00
|
|
|
case '--squirrel-updated':
|
|
|
|
case '--squirrel-obsolete':
|
2019-05-10 16:24:22 +00:00
|
|
|
app.quit();
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-10 19:20:07 +00:00
|
|
|
|
2019-05-10 16:24:22 +00:00
|
|
|
return false;
|
|
|
|
}
|