Make sure the app correctly quits in the initial set up
This commit is contained in:
@@ -5,7 +5,8 @@ function shouldQuitApp(cmd) {
|
||||
if (process.platform !== 'win32') {
|
||||
return false;
|
||||
}
|
||||
return ['--squirrel-install', '--squirrel-updated', '--squirrel-uninstall', '--squirrel-obsolete'].includes(cmd);
|
||||
const squirrelCommands = ['--squirrel-install', '--squirrel-updated', '--squirrel-uninstall', '--squirrel-obsolete'];
|
||||
return squirrelCommands.includes(cmd);
|
||||
}
|
||||
|
||||
async function setupAutoLaunch(cmd) {
|
||||
@@ -15,22 +16,23 @@ async function setupAutoLaunch(cmd) {
|
||||
});
|
||||
if (cmd === '--squirrel-uninstall') {
|
||||
// If we're uninstalling, make sure we also delete our auto launch registry key
|
||||
return appLauncher.disable();
|
||||
await appLauncher.disable();
|
||||
} else if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
|
||||
// If we're updating and already have an registry entry for auto launch, make sure to update the path
|
||||
const enabled = await appLauncher.isEnabled();
|
||||
if (enabled) {
|
||||
return appLauncher.enable();
|
||||
await appLauncher.enable();
|
||||
}
|
||||
}
|
||||
return async () => true;
|
||||
}
|
||||
|
||||
export default function squirrelStartup() {
|
||||
export default function squirrelStartup(callback) {
|
||||
if (process.platform === 'win32') {
|
||||
const cmd = process.argv[1];
|
||||
setupAutoLaunch(cmd).then(() => {
|
||||
require('electron-squirrel-startup'); // eslint-disable-line global-require
|
||||
if (require('electron-squirrel-startup') && callback) { // eslint-disable-line global-require
|
||||
callback();
|
||||
}
|
||||
});
|
||||
return shouldQuitApp(cmd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user