Skip to content

Commit

Permalink
fix(nsis): StartApp doesn't work if menuCategory used
Browse files Browse the repository at this point in the history
Close #1151, Close #1412
  • Loading branch information
develar committed Mar 28, 2017
1 parent 5a2631c commit 683d58c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default class NsisTarget extends Target {
defines.allowToChangeInstallationDirectory = null
}

if (options.menuCategory != null) {
if (options.menuCategory != null && options.menuCategory !== false) {
const menu = sanitizeFileName(options.menuCategory === true ? packager.appInfo.companyName : <string>options.menuCategory)
if (!isEmptyOrSpaces(menu)) {
defines.MENU_FILENAME = menu
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/templates/nsis/boringInstaller.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
!ifndef BUILD_UNINSTALLER
Function StartApp
${if} ${Updated}
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "--updated"
${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" "--updated"
${else}
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" ""
${StdUtils.ExecShellAsUser} $0 "$startMenuLink" "open" ""
${endif}
FunctionEnd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ WinShell::SetLnkAUMI "$desktopLink" "${APP_ID}"
${IfNot} ${Silent}
# otherwise app window will be in backround
HideWindow
Call StartApp
!insertmacro StartApp
${EndIf}
!endif
!insertmacro quitSuccess
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-builder/templates/nsis/installer.nsi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Var startMenuLink
Var desktopLink

!include "common.nsh"
!include "MUI2.nsh"
!include "multiUser.nsh"
Expand All @@ -23,9 +26,6 @@
!insertmacro customHeader
!endif

Var startMenuLink
Var desktopLink

!ifdef BUILD_UNINSTALLER
SilentInstall silent
!else
Expand Down
19 changes: 11 additions & 8 deletions packages/electron-builder/templates/nsis/oneClick.nsh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
!ifndef BUILD_UNINSTALLER
!ifdef RUN_AFTER_FINISH
!include StdUtils.nsh
Function StartApp
!macro StartApp
Var /GLOBAL startAppArgs
${if} ${Updated}
StrCpy $startAppArgs "--updated"
${else}
StrCpy $startAppArgs ""
${endif}

!ifdef INSTALL_MODE_PER_ALL_USERS
${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" ""
${StdUtils.ExecShellAsUser} $0 $startMenuLink "open" "$startAppArgs"
!else
${if} ${Updated}
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "--updated"
${else}
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"
${endif}
ExecShell "" "$startMenuLink" "$startAppArgs"
!endif
FunctionEnd
!macroend
!endif

!ifmacrodef licensePage
Expand Down
2 changes: 1 addition & 1 deletion test/src/windows/oneClickInstallerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test.ifAll("menuCategory", app({
},
config: {
nsis: {
perMachine: true,
oneClick: false,
menuCategory: true,
artifactName: "${productName} CustomName ${version}.${ext}"
},
Expand Down

0 comments on commit 683d58c

Please sign in to comment.