Skip to content

Commit 505a63d

Browse files
committed
feat(nsis): Pass --update flag to uninstaller when auto updating an application
Close #1162
1 parent 5d72c10 commit 505a63d

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

packages/electron-builder-util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"debug": "2.6.0",
2020
"node-emoji": "^1.5.1",
2121
"electron-builder-http": "~0.0.0-semantic-release",
22-
"source-map-support": "^0.4.10",
22+
"source-map-support": "^0.4.11",
2323
"7zip-bin": "^2.0.4"
2424
},
2525
"typings": "./out/electron-builder-util.d.ts"

packages/electron-builder/templates/nsis/installSection.nsh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,20 @@
3030
${endif}
3131

3232
ClearErrors
33-
${GetParameters} $R4
34-
${GetOptions} $R4 "--delete-app-data" $R5
33+
${GetParameters} $R0
34+
${GetOptions} $R0 "--update" $R2
3535
${ifNot} ${Errors}
36-
StrCpy $1 "--delete-app-data"
37-
${else}
38-
StrCpy $1 ""
36+
StrCpy $0 "$0 --update"
37+
${endif}
38+
39+
ClearErrors
40+
${GetParameters} $R0
41+
${GetOptions} $R0 "--delete-app-data" $R2
42+
${ifNot} ${Errors}
43+
StrCpy $0 "$0 --delete-app-data"
3944
${endif}
4045

41-
ExecWait '"$PLUGINSDIR\old-uninstaller.exe" /S /KEEP_APP_DATA $0 $1 _?=$R1'
46+
ExecWait '"$PLUGINSDIR\old-uninstaller.exe" /S /KEEP_APP_DATA $0 _?=$R1'
4247
${endif}
4348
${endif}
4449
!macroend

packages/electron-builder/templates/nsis/multiUserUi.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Var RadioButtonLabel1
198198
StrCpy $7 "There is a per-user installation. ($perUserInstallationFolder)$\r$\nWill uninstall."
199199
!endif
200200
${else}
201-
StrCpy $7 "Fresh install for current user only"
201+
StrCpy $7 "Fresh install for current user only."
202202
${endif}
203203
SendMessage $0 ${BCM_SETSHIELD} 0 0 ; hide SHIELD
204204
${else} ; all users

packages/electron-builder/templates/nsis/oneClick.nsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
!else
88
${GetParameters} $R0
99
${GetOptions} $R0 "--update" $R1
10-
${IfNot} ${Errors}
10+
${ifNot} ${Errors}
1111
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "--updated"
12-
${Else}
12+
${else}
1313
ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"
1414
${endif}
1515
!endif

packages/electron-updater/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"fs-extra-p": "^3.1.0",
1717
"js-yaml": "^3.7.0",
1818
"semver": "^5.3.0",
19-
"source-map-support": "^0.4.10",
19+
"source-map-support": "^0.4.11",
2020
"electron-builder-http": "0.0.0-semantic-release"
2121
},
2222
"typings": "./out/electron-updater.d.ts"

packages/electron-updater/src/AppUpdater.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,16 @@ export abstract class AppUpdater extends EventEmitter {
151151
throw new Error(`Latest version (from update server) is not valid semver version: "${latestVersion}`)
152152
}
153153

154-
const currentVersion = parseVersion(this.app.getVersion())
154+
const currentVersionString = this.app.getVersion()
155+
const currentVersion = parseVersion(currentVersionString)
155156
if (currentVersion == null) {
156157
throw new Error(`App version is not valid semver version: "${currentVersion}`)
157158
}
158159

159160
if (!isVersionGreaterThan(latestVersion, currentVersion)) {
160161
this.updateAvailable = false
161162
if (this.logger != null) {
162-
this.logger.info(`Update for version ${versionInfo.version} is not available`)
163+
this.logger.info(`Update for version ${currentVersionString} is not available (latest version: ${versionInfo.version})`)
163164
}
164165
this.emit("update-not-available")
165166
return {

packages/electron-updater/src/GenericProvider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ export class GenericProvider extends Provider<UpdateInfo> {
2222
hostname: this.baseUrl.hostname,
2323
path: `${pathname}${this.baseUrl.search || ""}`,
2424
protocol: this.baseUrl.protocol,
25+
headers: Object.assign({"Cache-Control": "no-cache, no-store, must-revalidate"}, this.requestHeaders)
2526
}
2627
if (this.baseUrl.port != null) {
2728
options.port = parseInt(this.baseUrl.port, 10)
2829
}
29-
if (this.requestHeaders != null) {
30-
options.headers = this.requestHeaders
31-
}
3230
result = await request<UpdateInfo>(options)
3331
}
3432
catch (e) {

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,8 @@ istanbul-lib-source-maps@^1.1.0:
14831483
source-map "^0.5.3"
14841484

14851485
istanbul-reports@^1.0.0:
1486-
version "1.0.0"
1487-
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.0.tgz#24b4eb2b1d29d50f103b369bd422f6e640aa0777"
1486+
version "1.0.1"
1487+
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.1.tgz#9a17176bc4a6cbebdae52b2f15961d52fa623fbc"
14881488
dependencies:
14891489
handlebars "^4.0.3"
14901490

0 commit comments

Comments
 (0)