2019-05-10 16:24:22 +00:00
|
|
|
import { spawn } from 'child_process';
|
|
|
|
import { app } from 'electron';
|
2021-07-22 23:04:56 +00:00
|
|
|
import path from 'path';
|
2019-05-10 16:24:22 +00:00
|
|
|
|
|
|
|
function run(args, done) {
|
|
|
|
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
|
2021-05-12 06:35:00 +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;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
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;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
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
|
|
|
|
2021-07-01 20:47:10 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-10 16:24:22 +00:00
|
|
|
}
|