mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
39 lines
901 B
TypeScript
39 lines
901 B
TypeScript
import { spawn } from 'child_process';
|
|
import { app } from 'electron';
|
|
import path from 'path';
|
|
|
|
function run(args, done) {
|
|
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
|
|
spawn(updateExe, args, {
|
|
detached: true,
|
|
}).on('close', done);
|
|
}
|
|
|
|
export function checkIfRestartNeeded() {
|
|
if (process.platform !== 'win32') {
|
|
return false;
|
|
}
|
|
|
|
const cmd = process.argv[1];
|
|
console.log('processing squirrel command `%s`', cmd);
|
|
const target = path.basename(process.execPath);
|
|
|
|
switch (cmd) {
|
|
case '--squirrel-install':
|
|
run(['--createShortcut=' + target + ''], app.quit);
|
|
return true;
|
|
|
|
case '--squirrel-uninstall':
|
|
run(['--removeShortcut=' + target + ''], app.quit);
|
|
return true;
|
|
|
|
case '--squirrel-updated':
|
|
case '--squirrel-obsolete':
|
|
app.quit();
|
|
return true;
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
}
|