Skip to content

Commit

Permalink
feat(nsis): run after finish flag for one-click installer
Browse files Browse the repository at this point in the history
Closes #574
  • Loading branch information
develar committed Jul 13, 2016
1 parent 0022b86 commit 50039ea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| oneClick | <a name="NsisOptions-oneClick"></a>One-click installation. Defaults to `true`.
| perMachine | <a name="NsisOptions-perMachine"></a>Install per all users (per-machine). Defaults to `false`.
| 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`.
| runAfterFinish | <a name="NsisOptions-runAfterFinish"></a>*one-click installer only.* Run application after finish. Defaults to `true`.
| installerHeader | <a name="NsisOptions-installerHeader"></a>*boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
| 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.

Expand Down
5 changes: 5 additions & 0 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ export interface NsisOptions {
*/
readonly allowElevation?: boolean | null

/*
*one-click installer only.* Run application after finish. Defaults to `true`.
*/
readonly runAfterFinish?: boolean | null

readonly guid?: string | null

/*
Expand Down
7 changes: 6 additions & 1 deletion src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ export default class NsisTarget extends Target {
defines.INSTALL_MODE_PER_ALL_USERS = null
}

if (!oneClick && this.options.allowElevation !== false) {
if (oneClick) {
if (this.options.runAfterFinish !== false) {
defines.RUN_AFTER_FINISH = null
}
}
else if (this.options.allowElevation !== false) {
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
}

Expand Down
4 changes: 3 additions & 1 deletion templates/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ Section "install"
!ifdef ONE_CLICK
# otherwise app window will be in backround
HideWindow
Call StartApp
!ifdef RUN_AFTER_FINISH
Call StartApp
!endif
!endif
SectionEnd

Expand Down
3 changes: 2 additions & 1 deletion test/src/winPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ test("nsis", () => assertPack("test-app-one", _signed({
}
))

test.ifDevOrLinuxCi("nsis 32 perMachine", () => assertPack("test-app-one", {
test.ifDevOrLinuxCi("nsis 32 perMachine, no run after finish", () => assertPack("test-app-one", {
targets: Platform.WINDOWS.createTarget(["nsis"], Arch.ia32),
devMetadata: {
build: {
nsis: {
perMachine: true,
runAfterFinish: false,
}
}
}
Expand Down

0 comments on commit 50039ea

Please sign in to comment.