Skip to content

Commit

Permalink
fix: trigger app.relaunch() if isForceRunAfter = true for rpm and…
Browse files Browse the repository at this point in the history
… deb updaters (#7637)
  • Loading branch information
mmaietta authored Jun 27, 2023
1 parent 8ae9061 commit b3dfe64
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
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
}
}

0 comments on commit b3dfe64

Please sign in to comment.