Skip to content

Commit

Permalink
feat(nsis): option to not create desktop shortcut
Browse files Browse the repository at this point in the history
Close #1597
  • Loading branch information
develar committed Jun 26, 2017
1 parent 02dd8a1 commit 350e241
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Configuration Options
If `oneClick` is `false`: no install mode installer page (choice per-machine or per-user), always install per-machine.
* <a name="NsisOptions-allowElevation"></a>`allowElevation` = `true` Boolean - *boring installer only.* Allow requesting for elevation. If false, user will have to restart installer with elevated permissions.
* <a name="NsisOptions-allowToChangeInstallationDirectory"></a>`allowToChangeInstallationDirectory` = `false` Boolean - *boring installer only.* Whether to allow user to change installation directory.
* <a name="NsisOptions-createDesktopShortcut"></a>`createDesktopShortcut` = `true` Boolean - Whether to create desktop shortcut.
* <a name="NsisOptions-runAfterFinish"></a>`runAfterFinish` = `true` Boolean - *one-click installer only.* Run application after finish.
* <a name="NsisOptions-installerIcon"></a>`installerIcon` String - The path to installer icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `build/installerIcon.ico` or application icon.
* <a name="NsisOptions-uninstallerIcon"></a>`uninstallerIcon` String - The path to uninstaller icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `build/uninstallerIcon.ico` or application icon.
Expand Down
6 changes: 6 additions & 0 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export interface NsisOptions extends CommonNsisOptions, TargetSpecificOptions {
*/
readonly allowToChangeInstallationDirectory?: boolean

/**
* Whether to create desktop shortcut.
* @default true
*/
readonly createDesktopShortcut?: boolean

/**
* *one-click installer only.* Run application after finish.
* @default true
Expand Down
5 changes: 4 additions & 1 deletion packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ export class NsisTarget extends Target {
defines.MUI_UNICON = uninstallerIcon
}

defines.UNINSTALL_DISPLAY_NAME = packager.expandMacro(this.options.uninstallDisplayName || "${productName} ${version}", null, {}, false)
defines.UNINSTALL_DISPLAY_NAME = packager.expandMacro(options.uninstallDisplayName || "${productName} ${version}", null, {}, false)
if (options.createDesktopShortcut === false) {
defines.DO_NOT_CREATE_DESKTOP_SHORTCUT = null
}
}

private configureDefinesForAllTypeOfInstaller(defines: any) {
Expand Down
20 changes: 12 additions & 8 deletions packages/electron-builder/templates/nsis/installSection.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@ ${endif}

StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
Var /GLOBAL shortcuts
StrCpy $shortcuts ""
!ifndef allowToChangeInstallationDirectory
ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts

${if} $R1 == "true"
${andIf} ${FileExists} "$appExe"
StrCpy $shortcuts "--keep-shortcuts"
${endIf}
!ifdef DO_NOT_CREATE_DESKTOP_SHORTCUT
StrCpy $shortcuts "--keep-shortcuts"
!else
StrCpy $shortcuts ""
!ifndef allowToChangeInstallationDirectory
ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts

${if} $R1 == "true"
${andIf} ${FileExists} "$appExe"
StrCpy $shortcuts "--keep-shortcuts"
${endIf}
!endif
!endif

!ifdef ONE_CLICK
Expand Down
1 change: 1 addition & 0 deletions test/src/windows/oneClickInstallerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ test.ifAll.ifNotCiMac("multi language license", app({
publish: null,
nsis: {
uninstallDisplayName: "Hi!!!",
createDesktopShortcut: false,
}
},
}, {
Expand Down

0 comments on commit 350e241

Please sign in to comment.