From 984a98b9df9a72a4ca7370096ed9ffeec7423b35 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 27 Jul 2021 11:47:44 +0100 Subject: [PATCH] Fix issue with Squirrel.Windows install/update handler not firing properly --- src/electron-main.ts | 8 ++------ src/squirrelhooks.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/electron-main.ts b/src/electron-main.ts index 6782d3a..08df924 100644 --- a/src/electron-main.ts +++ b/src/electron-main.ts @@ -17,12 +17,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Squirrel on windows starts the app with various flags -// as hooks to tell us when we've been installed/uninstalled -// etc. -import { checkSquirrelHooks } from "./squirrelhooks"; -if (checkSquirrelHooks()) process.exit(1); - +// Squirrel on windows starts the app with various flags as hooks to tell us when we've been installed/uninstalled etc. +import "./squirrelhooks"; import { app, ipcMain, powerSaveBlocker, BrowserWindow, Menu, autoUpdater, protocol, dialog } from "electron"; import AutoLaunch from "auto-launch"; import path from "path"; diff --git a/src/squirrelhooks.ts b/src/squirrelhooks.ts index 9863312..0119a1a 100644 --- a/src/squirrelhooks.ts +++ b/src/squirrelhooks.ts @@ -33,15 +33,13 @@ function runUpdateExe(args: string[]): Promise { }); } -export function checkSquirrelHooks(): boolean { +function checkSquirrelHooks(): boolean { if (process.platform !== 'win32') return false; const cmd = process.argv[1]; const target = path.basename(process.execPath); if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') { - Promise.resolve().then(() => { - return runUpdateExe(['--createShortcut=' + target]); - }).then(() => { + runUpdateExe(['--createShortcut=' + target]).then(() => { // remove the old 'Riot' shortcuts, if they exist (update.exe --removeShortcut doesn't work // because it always uses the name of the product as the name of the shortcut: the only variable // is what executable you're linking to) @@ -82,3 +80,7 @@ export function checkSquirrelHooks(): boolean { } return false; } + +if (checkSquirrelHooks()) { + process.exit(1); +}