diff --git a/electron-builder.yml b/electron-builder.yml index a1278c3..60d990e 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -48,5 +48,6 @@ nsis: oneClick: false perMachine: true allowElevation: true + runAfterFinish: true differentialPackage: false artifactName: Switchify-PC-Setup-${version}-${arch}.${ext} diff --git a/src/main/updates/update-service.test.ts b/src/main/updates/update-service.test.ts index eeb835e..6910288 100644 --- a/src/main/updates/update-service.test.ts +++ b/src/main/updates/update-service.test.ts @@ -138,7 +138,7 @@ describe('UpdateService', () => { expect(updater.quitAndInstall).not.toHaveBeenCalled(); }); - it('calls quitAndInstall after an update is downloaded', async () => { + it('installs downloaded updates silently and relaunches the app', async () => { const updater = new FakeUpdater(); updater.checkForUpdates.mockImplementation(async () => { updater.emit('update-available', updateInfo({ version: '0.1.1' })); @@ -153,7 +153,7 @@ describe('UpdateService', () => { await service.downloadUpdate(); expect(service.installDownloadedUpdate()).toEqual({ ok: true }); - expect(updater.quitAndInstall).toHaveBeenCalledWith(false, true); + expect(updater.quitAndInstall).toHaveBeenCalledWith(true, true); }); it('maps updater errors during checks to check_failed', async () => { diff --git a/src/main/updates/update-service.ts b/src/main/updates/update-service.ts index 55c8b8d..dd6eea0 100644 --- a/src/main/updates/update-service.ts +++ b/src/main/updates/update-service.ts @@ -28,6 +28,9 @@ export type UpdateServiceOptions = { type UpdateOperation = 'idle' | 'checking' | 'downloading'; +const INSTALL_UPDATE_SILENTLY = true; +const FORCE_RUN_AFTER_INSTALL = true; + export class UpdateService { private readonly isPackaged: boolean; private readonly platform: NodeJS.Platform; @@ -182,7 +185,7 @@ export class UpdateService { return { ok: false, reason: 'not_downloaded' }; } - this.autoUpdater.quitAndInstall(false, true); + this.autoUpdater.quitAndInstall(INSTALL_UPDATE_SILENTLY, FORCE_RUN_AFTER_INSTALL); return { ok: true }; } diff --git a/src/renderer/components/UpdatesPanel.tsx b/src/renderer/components/UpdatesPanel.tsx index 111bb8d..4ca3bd6 100644 --- a/src/renderer/components/UpdatesPanel.tsx +++ b/src/renderer/components/UpdatesPanel.tsx @@ -56,7 +56,7 @@ export function UpdatesPanel({ ) : null} {showInstallButton ? ( ) : null}