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

feat(nsis): Add flag to force start on silent install #1712

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions packages/electron-builder/templates/nsis/common.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Name "${PRODUCT_NAME}"
!macroend
!define Updated `"" Updated ""`

!macro _ForceRun _a _b _t _f
ClearErrors
${GetParameters} $R9
${GetOptions} $R9 "--force-run" $R8
IfErrors `${_f}` `${_t}`
!macroend
!define ForceRun `"" ForceRun ""`


!macro extractEmbeddedAppPackage
!ifdef COMPRESS
SetCompress off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ ${endif}
!ifdef ONE_CLICK
!ifdef RUN_AFTER_FINISH
${IfNot} ${Silent}
${OrIf} ${ForceRun}
# otherwise app window will be in backround
HideWindow
!insertmacro StartApp
Expand Down
13 changes: 9 additions & 4 deletions packages/electron-updater/src/NsisUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ export class NsisUpdater extends AppUpdater {

this.app.on("quit", () => {
this._logger.info("Auto install update on quit")
this.install(true)
this.install(true, false)
})
}

quitAndInstall(isSilent: boolean = false): void {
if (this.install(isSilent)) {
quitAndInstall(isSilent: boolean = false, forceRunAfter: boolean = false): void {
if (this.install(isSilent, forceRunAfter)) {
this.app.quit()
}
}

private install(isSilent: boolean): boolean {
private install(isSilent: boolean, forceRunAfter: boolean): boolean {
if (this.quitAndInstallCalled) {
return false
}
Expand All @@ -163,6 +163,11 @@ export class NsisUpdater extends AppUpdater {
if (isSilent) {
args.push("/S")
}

if (forceRunAfter) {
args.push("--force-run")
}

const spawnOptions = {
detached: true,
stdio: "ignore",
Expand Down