Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trigger app.relaunch() if isForceRunAfter = true for rpm and deb updaters #7637

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-pears-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix: trigger `app.relaunch()` if `isForceRunAfter = true` for (beta) deb and rpm updaters
2 changes: 2 additions & 0 deletions packages/electron-updater/src/AppAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface AppAdapter {

whenReady(): Promise<void>

relaunch(): void

quit(): void

onQuit(handler: (exitCode: number) => void): void
Expand Down
3 changes: 3 additions & 0 deletions packages/electron-updater/src/DebUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export class DebUpdater extends BaseUpdater {
const wrapper = /pkexec/i.test(sudo) ? "" : `"`
const cmd = ["dpkg", "-i", options.installerPath, "||", "apt-get", "install", "-f", "-y"]
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`])
if (options.isForceRunAfter) {
this.app.relaunch()
}
return true
}
}
4 changes: 4 additions & 0 deletions packages/electron-updater/src/ElectronAppAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export class ElectronAppAdapter implements AppAdapter {
this.app.quit()
}

relaunch(): void {
this.app.relaunch()
}

onQuit(handler: (exitCode: number) => void): void {
this.app.once("quit", (_: Event, exitCode: number) => handler(exitCode))
}
Expand Down
3 changes: 3 additions & 0 deletions packages/electron-updater/src/RpmUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class RpmUpdater extends BaseUpdater {
]
}
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`])
if (options.isForceRunAfter) {
this.app.relaunch()
}
return true
}
}