From be2fe97741952cb786fcb693a1f4b600c690e32e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E7=94=9F=E7=82=BC?= Modules
@@ -1428,11 +1428,13 @@ return path.join(target.outDir,
__${target.name}-${getArtifactArchName(arc
.setFeedURL(options)
.isUpdaterActive()
⇒ Boolean
.quitAndInstall(isSilent, isForceRunAfter)
.quitAppAndInstall(isForceRunAfter)
AppUpdater
.quitAndInstall()
.quitAppAndInstall()
.addAuthHeader(token)
.checkForUpdates()
⇒ Promise< | UpdateCheckResult>
.checkForUpdatesAndNotify(downloadNotification)
⇒ Promise< | UpdateCheckResult>
__${target.name}-${getArtifactArchName(arc
.setFeedURL(options)
.isUpdaterActive()
⇒ Boolean
.quitAndInstall(isSilent, isForceRunAfter)
.quitAppAndInstall(isForceRunAfter)
appUpdater.quitAppAndInstall(isForceRunAfter)
Quit the app and explicit installs the update after it has been downloaded.
+It should only be called after update-downloaded
has been emitted.
Note: autoUpdater.quitAppAndInstall()
will close all application windows first and only emit before-quit
event on app
after that.
+This is different from the normal quit event sequence.
Param | +Type | +Description | +
---|---|---|
isForceRunAfter | +Boolean |
+Run the app after finish even on silent install. Not applicable for macOS. | +
AppUpdater
Kind: class of electron-updater
@@ -1757,6 +1782,7 @@ This is different from the normal quit event sequence.
AppUpdater
.quitAndInstall()
.quitAppAndInstall()
.addAuthHeader(token)
.checkForUpdates()
⇒ Promise< | UpdateCheckResult>
.checkForUpdatesAndNotify(downloadNotification)
⇒ Promise< | UpdateCheckResult>
macUpdater.quitAndInstall()
Overrides: quitAndInstall
+
macUpdater.quitAppAndInstall()
Overrides: quitAppAndInstall
macUpdater.addAuthHeader(token)
Shortcut for explicitly adding auth tokens to request headers
diff --git a/packages/electron-updater/src/AppUpdater.ts b/packages/electron-updater/src/AppUpdater.ts index a3afa1299a..d07de9aeea 100644 --- a/packages/electron-updater/src/AppUpdater.ts +++ b/packages/electron-updater/src/AppUpdater.ts @@ -517,6 +517,17 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter */ abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void + /** + * Quit the app and explicit installs the update after it has been downloaded. + * It should only be called after `update-downloaded` has been emitted. + * + * **Note:** `autoUpdater.quitAppAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that. + * This is different from the normal quit event sequence. + * + * @param isForceRunAfter Run the app after finish. Defaults to `false`. Not applicable for macOS. + */ + abstract quitAppAndInstall(isForceRunAfter?: boolean): void + private async loadUpdateConfig(): Promise__${target.name}-${getArtifactArchName(arc
.setFeedURL(options)
.isUpdaterActive()
⇒ Boolean
.quitAndInstall(isSilent, isForceRunAfter)
-.quitAppAndInstall(isForceRunAfter)
AppUpdater
.quitAndInstall()
.quitAppAndInstall()
.addAuthHeader(token)
.checkForUpdates()
⇒ Promise< | UpdateCheckResult>
.checkForUpdatesAndNotify(downloadNotification)
⇒ Promise< | UpdateCheckResult>
__${target.name}-${getArtifactArchName(arc
autoInstallOnAppQuit
= true
Boolean - Whether to automatically install a downloaded update on app quit (if quitAndInstall
was not called before).
autoRunAppAfterInstall
= true
Boolean - windows-only Whether to run the app after finish install when run the installer NOT in silent mode.
allowPrerelease
= false
Boolean - GitHub provider only. Whether to allow update to pre-release versions. Defaults to true
if application version contains prerelease components (e.g. 0.12.1-alpha.1
, here alpha
is a prerelease component), otherwise false
.
If true
, downgrade will be allowed (allowDowngrade
will be set to true
).
__${target.name}-${getArtifactArchName(arc
.setFeedURL(options)
.isUpdaterActive()
⇒ Boolean
.quitAndInstall(isSilent, isForceRunAfter)
-.quitAppAndInstall(isForceRunAfter)
@@ -1748,29 +1748,7 @@ This is different from the normal quit event sequence.
isForceRunAfter
Boolean
-Run the app after finish even on silent install. Not applicable for macOS. Ignored if isSilent
is set to false
.
-
-
-
-
-appUpdater.quitAppAndInstall(isForceRunAfter)
-Quit the app and explicit installs the update after it has been downloaded.
-It should only be called after update-downloaded
has been emitted.
-Note: autoUpdater.quitAppAndInstall()
will close all application windows first and only emit before-quit
event on app
after that.
-This is different from the normal quit event sequence.
-
-
-
-Param
-Type
-Description
-
-
-
-
-isForceRunAfter
-Boolean
-Run the app after finish even on silent install. Not applicable for macOS.
+Run the app after finish even on silent install. Not applicable for macOS. Ignored if isSilent
is set to false
(In this case you can still set autoRunAppAfterInstall
to false
to prevent run the app)
@@ -1782,7 +1760,6 @@ This is different from the normal quit event sequence.
.MacUpdater ⇐ AppUpdater
.quitAndInstall()
-.quitAppAndInstall()
.addAuthHeader(token)
.checkForUpdates()
⇒ Promise< | UpdateCheckResult>
.checkForUpdatesAndNotify(downloadNotification)
⇒ Promise< | UpdateCheckResult>
@@ -1796,9 +1773,6 @@ This is different from the normal quit event sequence.
macUpdater.quitAndInstall()
Overrides: quitAndInstall
-
-macUpdater.quitAppAndInstall()
-Overrides: quitAppAndInstall
macUpdater.addAuthHeader(token)
Shortcut for explicitly adding auth tokens to request headers
diff --git a/packages/electron-updater/src/AppUpdater.ts b/packages/electron-updater/src/AppUpdater.ts
index d07de9aeea..92e4c98768 100644
--- a/packages/electron-updater/src/AppUpdater.ts
+++ b/packages/electron-updater/src/AppUpdater.ts
@@ -53,6 +53,12 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
*/
autoInstallOnAppQuit = true
+ /**
+ * *windows-only* Whether to run the app after finish install when run the installer NOT in silent mode.
+ * @default true
+ */
+ autoRunAppAfterInstall = true
+
/**
* *GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.
*
@@ -513,21 +519,11 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
* This is different from the normal quit event sequence.
*
* @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.
- * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.
+ * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.
+ * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).
*/
abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void
- /**
- * Quit the app and explicit installs the update after it has been downloaded.
- * It should only be called after `update-downloaded` has been emitted.
- *
- * **Note:** `autoUpdater.quitAppAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.
- * This is different from the normal quit event sequence.
- *
- * @param isForceRunAfter Run the app after finish. Defaults to `false`. Not applicable for macOS.
- */
- abstract quitAppAndInstall(isForceRunAfter?: boolean): void
-
private async loadUpdateConfig(): Promise {
if (this._appUpdateConfigPath == null) {
this._appUpdateConfigPath = this.app.appUpdateConfigPath
diff --git a/packages/electron-updater/src/BaseUpdater.ts b/packages/electron-updater/src/BaseUpdater.ts
index d291e80e29..c4170b599c 100644
--- a/packages/electron-updater/src/BaseUpdater.ts
+++ b/packages/electron-updater/src/BaseUpdater.ts
@@ -12,7 +12,8 @@ export abstract class BaseUpdater extends AppUpdater {
quitAndInstall(isSilent = false, isForceRunAfter = false): void {
this._logger.info(`Install on explicit quitAndInstall`)
- const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : true)
+ // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app
+ const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)
if (isInstalled) {
setImmediate(() => {
// this event is normally emitted when calling quitAndInstall, this emulates that
@@ -24,18 +25,6 @@ export abstract class BaseUpdater extends AppUpdater {
}
}
- quitAppAndInstall(isForceRunAfter = false): void {
- const isInstalled = this.install(false, isForceRunAfter);
- if (isInstalled) {
- setImmediate(() => {
- require("electron").autoUpdater.emit("before-quit-for-update")
- this.app.quit()
- })
- } else {
- this.quitAndInstallCalled = false
- }
- }
-
protected executeDownload(taskOptions: DownloadExecutorTask): Promise> {
return super.executeDownload({
...taskOptions,
diff --git a/packages/electron-updater/src/MacUpdater.ts b/packages/electron-updater/src/MacUpdater.ts
index 639786a579..f2dd2162aa 100644
--- a/packages/electron-updater/src/MacUpdater.ts
+++ b/packages/electron-updater/src/MacUpdater.ts
@@ -233,8 +233,4 @@ export class MacUpdater extends AppUpdater {
}
}
}
-
- quitAppAndInstall(): void {
- this.quitAndInstall();
- }
}
From 5fd2b5aea06cd5792f6f36c261509bf593960de2 Mon Sep 17 00:00:00 2001
From: Mike Maietta
Date: Fri, 30 Sep 2022 08:22:51 -0700
Subject: [PATCH 3/3] Create chilly-days-yawn.md
---
.changeset/chilly-days-yawn.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/chilly-days-yawn.md
diff --git a/.changeset/chilly-days-yawn.md b/.changeset/chilly-days-yawn.md
new file mode 100644
index 0000000000..7baf836338
--- /dev/null
+++ b/.changeset/chilly-days-yawn.md
@@ -0,0 +1,5 @@
+---
+"electron-updater": minor
+---
+
+feat: non-silent mode allow not to run the app when the installation is complete