insomnia/packages/insomnia-app/app/main/squirrel-startup.js

34 lines
875 B
JavaScript
Raw Normal View History

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: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 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 19:20:07 +00:00
switch (cmd) {
case '--squirrel-install':
run(['--createShortcut=' + target + ''], app.quit);
return true;
2019-05-10 19:20:07 +00:00
case '--squirrel-uninstall':
run(['--removeShortcut=' + target + ''], app.quit);
return true;
2019-05-10 19:20:07 +00:00
case '--squirrel-updated':
case '--squirrel-obsolete':
app.quit();
return true;
}
2019-05-10 19:20:07 +00:00
return false;
}