• Processes Squirrel.Windows installer events

    Handles specific Squirrel commands for Windows desktop integration, creating or removing shortcuts and performing necessary installation tasks. Exits the app after handling installation events.

    Parameters

    • Optionalcommand: string

      The Squirrel command received from the installer (from process.argv)

    Returns boolean

    True if an event was handled, false otherwise

    export function handleSquirrelEvent(command?: string): boolean {
    if (process.platform !== "win32" || !command) {
    return false;
    }

    switch (command) {
    case "--squirrel-install":
    case "--squirrel-updated": {
    // Create desktop and start menu shortcuts when the app is installed or updated
    const target = path.basename(process.execPath);
    const updateDotExe = path.resolve(
    path.dirname(process.execPath),
    "..",
    "Update.exe",
    );
    const cmd = `"${updateDotExe}" --createShortcut="${target}"`;
    exec(cmd);
    setTimeout(() => app.quit(), 1000);
    return true;
    }

    case "--squirrel-uninstall": {
    // Remove shortcuts created during installation
    const target = path.basename(process.execPath);
    const updateDotExe = path.resolve(
    path.dirname(process.execPath),
    "..",
    "Update.exe",
    );
    const cmd = `"${updateDotExe}" --removeShortcut="${target}"`;
    exec(cmd);

    // Just exit the app cleanly - Windows will handle the uninstall UI
    console.log("Uninstalling Spotify Skip Tracker...");
    setTimeout(() => app.quit(), 500);
    return true;
    }

    case "--squirrel-obsolete":
    // This is called on the outgoing version of your app before
    // we update to the new version - it's the opposite of
    // --squirrel-updated
    app.quit();
    return true;

    default:
    return false;
    }
    }