Skip to content

Commit

Permalink
fix(nsis): get InstallLocation from UninstallerString if not found #735
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Sep 14, 2016
1 parent cca23b4 commit 431922e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/build-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (process.env.CI == null && process.env.NO_UPDATE_NOTIFIER == null) {
const notifier = updateNotifier({pkg: it})
if (notifier.update != null) {
notifier.notify({
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("npm i electron-builder")} to update`
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("npm i electron-builder --save-dev")} to update`
})
}
})
Expand Down
25 changes: 25 additions & 0 deletions templates/nsis/common.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,29 @@ Function GetInQuotes
Pop $R1
Exch $R0
FunctionEnd

Function GetFileParent
Exch $R0
Push $R1
Push $R2
Push $R3

StrCpy $R1 0
StrLen $R2 $R0

loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop

get:
StrCpy $R0 $R0 -$R1

Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
!endif
13 changes: 10 additions & 3 deletions templates/nsis/installSection.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@
Pop $R0

ReadRegStr $R1 ${ROOT_KEY} "${INSTALL_REGISTRY_KEY}" InstallLocation
${if} $R1 == ""
${andIf} $R0 != ""
# https://github.com/electron-userland/electron-builder/issues/735#issuecomment-246918567
Push $R0
Call GetFileParent
Pop $R1
${endif}

${if} $R1 != ""
${AndIf} $R0 != ""
${andIf} $R0 != ""
CopyFiles /SILENT /FILESONLY "$R0" "$PLUGINSDIR\old-uninstaller.exe"

${if} $installMode == "CurrentUser"
${OrIf} ${ROOT_KEY} == "HKEY_CURRENT_USER"
${orIf} ${ROOT_KEY} == "HKEY_CURRENT_USER"
StrCpy $0 "/currentuser"
${else}
StrCpy $0 "/allusers"
${endif}
# MessageBox MB_OK|MB_ICONEXCLAMATION '"$PLUGINSDIR\old-uninstaller.exe" "_?=$R1" /S /KEEP_APP_DATA $0'
ExecWait '"$PLUGINSDIR\old-uninstaller.exe" "_?=$R1" /S /KEEP_APP_DATA $0'
${endif}
${endif}
Expand Down

0 comments on commit 431922e

Please sign in to comment.