Skip to content

Commit 50039ea

Browse files
committed
feat(nsis): run after finish flag for one-click installer
Closes #574
1 parent 0022b86 commit 50039ea

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

docs/Options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
130130
| oneClick | <a name="NsisOptions-oneClick"></a>One-click installation. Defaults to `true`.
131131
| perMachine | <a name="NsisOptions-perMachine"></a>Install per all users (per-machine). Defaults to `false`.
132132
| allowElevation | <a name="NsisOptions-allowElevation"></a>*boring installer only.* Allow requesting for elevation. If false, user will have to restart installer with elevated permissions. Defaults to `true`.
133+
| runAfterFinish | <a name="NsisOptions-runAfterFinish"></a>*one-click installer only.* Run application after finish. Defaults to `true`.
133134
| installerHeader | <a name="NsisOptions-installerHeader"></a>*boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
134135
| installerHeaderIcon | <a name="NsisOptions-installerHeaderIcon"></a>*one-click installer only.* The path to header icon (above the progress bar), relative to the project directory. Defaults to `build/installerHeaderIcon.ico` or application icon.
135136

src/metadata.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ export interface NsisOptions {
372372
*/
373373
readonly allowElevation?: boolean | null
374374

375+
/*
376+
*one-click installer only.* Run application after finish. Defaults to `true`.
377+
*/
378+
readonly runAfterFinish?: boolean | null
379+
375380
readonly guid?: string | null
376381

377382
/*

src/targets/nsis.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ export default class NsisTarget extends Target {
9191
defines.INSTALL_MODE_PER_ALL_USERS = null
9292
}
9393

94-
if (!oneClick && this.options.allowElevation !== false) {
94+
if (oneClick) {
95+
if (this.options.runAfterFinish !== false) {
96+
defines.RUN_AFTER_FINISH = null
97+
}
98+
}
99+
else if (this.options.allowElevation !== false) {
95100
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
96101
}
97102

templates/nsis/installer.nsi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ Section "install"
114114
!ifdef ONE_CLICK
115115
# otherwise app window will be in backround
116116
HideWindow
117-
Call StartApp
117+
!ifdef RUN_AFTER_FINISH
118+
Call StartApp
119+
!endif
118120
!endif
119121
SectionEnd
120122

test/src/winPackagerTest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ test("nsis", () => assertPack("test-app-one", _signed({
3434
}
3535
))
3636

37-
test.ifDevOrLinuxCi("nsis 32 perMachine", () => assertPack("test-app-one", {
37+
test.ifDevOrLinuxCi("nsis 32 perMachine, no run after finish", () => assertPack("test-app-one", {
3838
targets: Platform.WINDOWS.createTarget(["nsis"], Arch.ia32),
3939
devMetadata: {
4040
build: {
4141
nsis: {
4242
perMachine: true,
43+
runAfterFinish: false,
4344
}
4445
}
4546
}

0 commit comments

Comments
 (0)