diff --git a/src/electron-main.ts b/src/electron-main.ts index 9b4b9f90..46a9e022 100644 --- a/src/electron-main.ts +++ b/src/electron-main.ts @@ -46,6 +46,7 @@ import { setupMacosTitleBar } from "./macos-titlebar.js"; import { type Json, loadJsonFile } from "./utils.js"; import { setupMediaAuth } from "./media-auth.js"; import { readBuildConfig } from "./build-config.js"; +import { checkSquirrelHooks } from "./squirrelhooks.js"; const __dirname = dirname(fileURLToPath(import.meta.url)); @@ -53,6 +54,21 @@ const argv = minimist(process.argv, { alias: { help: "h" }, }); +const buildConfig = readBuildConfig(); + +// This is required to make notification handlers work +// on Windows 8.1/10/11 (and is a noop on other platforms); +// It must also match the ID found in 'electron-builder' +// in order to get the title and icon to show up correctly. +// Ref: https://stackoverflow.com/a/77314604/3525780 +// Must be done before checkSquirrelHooks() as the hook needs +// to know what AppUserModelID to set on the shortcut. +app.setAppUserModelId(buildConfig.appId); + +if (checkSquirrelHooks()) { + process.exit(1); +} + if (argv["help"]) { console.log("Options:"); console.log(" --profile-dir {path}: Path to where to store the profile."); @@ -84,7 +100,6 @@ function isRealUserDataDir(d: string): boolean { return fs.existsSync(path.join(d, "IndexedDB")); } -const buildConfig = readBuildConfig(); const protocolHandler = new ProtocolHandler(buildConfig.protocol); // check if we are passed a profile in the SSO callback url @@ -626,9 +641,3 @@ app.on("second-instance", (ev, commandLine, workingDirectory) => { } }); -// This is required to make notification handlers work -// on Windows 8.1/10/11 (and is a noop on other platforms); -// It must also match the ID found in 'electron-builder' -// in order to get the title and icon to show up correctly. -// Ref: https://stackoverflow.com/a/77314604/3525780 -app.setAppUserModelId(buildConfig.appId); diff --git a/src/squirrelhooks.ts b/src/squirrelhooks.ts index 50b30a4e..7ed586d2 100644 --- a/src/squirrelhooks.ts +++ b/src/squirrelhooks.ts @@ -28,7 +28,7 @@ function runUpdateExe(args: string[]): Promise { }); } -function checkSquirrelHooks(): boolean { +export function checkSquirrelHooks(): boolean { if (process.platform !== "win32") return false; const cmd = process.argv[1]; const target = path.basename(process.execPath); @@ -51,7 +51,3 @@ function checkSquirrelHooks(): boolean { return false; } } - -if (checkSquirrelHooks()) { - process.exit(1); -}