Skip to content

Commit 4d989a8

Browse files
authored
feat: add option for quitAndInstall for non-silent update without restart (#7136)
1 parent 50d126e commit 4d989a8

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

.changeset/chilly-days-yawn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"electron-updater": minor
3+
---
4+
5+
feat: non-silent mode allow not to run the app when the installation is complete

docs/api/electron-builder.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Developer API only. See [Configuration](../configuration/configuration.md) for user documentation.
2-
2+
33
<!-- do not edit. start of generated block -->
44
<h1 id="modules">Modules</h1>
55
<dl>
@@ -1585,6 +1585,9 @@ return path.join(target.outDir, <code>__${target.name}-${getArtifactArchName(arc
15851585
<p><code id="AppUpdater-autoInstallOnAppQuit">autoInstallOnAppQuit</code> = <code>true</code> Boolean - Whether to automatically install a downloaded update on app quit (if <code>quitAndInstall</code> was not called before).</p>
15861586
</li>
15871587
<li>
1588+
<p><code id="AppUpdater-autoRunAppAfterInstall">autoRunAppAfterInstall</code> = <code>true</code> Boolean - <em>windows-only</em> Whether to run the app after finish install when run the installer <em>NOT in silent mode</em>.</p>
1589+
</li>
1590+
<li>
15881591
<p><code id="AppUpdater-allowPrerelease">allowPrerelease</code> = <code>false</code> Boolean - <em>GitHub provider only.</em> Whether to allow update to pre-release versions. Defaults to <code>true</code> if application version contains prerelease components (e.g. <code>0.12.1-alpha.1</code>, here <code>alpha</code> is a prerelease component), otherwise <code>false</code>.</p>
15891592
<p>If <code>true</code>, downgrade will be allowed (<code>allowDowngrade</code> will be set to <code>true</code>).</p>
15901593
</li>
@@ -1745,7 +1748,7 @@ This is different from the normal quit event sequence.</p>
17451748
<tr>
17461749
<td>isForceRunAfter</td>
17471750
<td><code>Boolean</code></td>
1748-
<td>Run the app after finish even on silent install. Not applicable for macOS. Ignored if <code>isSilent</code> is set to <code>false</code>.</td>
1751+
<td>Run the app after finish even on silent install. Not applicable for macOS. Ignored if <code>isSilent</code> is set to <code>false</code>(In this case you can still set <code>autoRunAppAfterInstall</code> to <code>false</code> to prevent run the app)</td>
17491752
</tr>
17501753
</tbody>
17511754
</table>

packages/electron-updater/src/AppUpdater.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
5353
*/
5454
autoInstallOnAppQuit = true
5555

56+
/**
57+
* *windows-only* Whether to run the app after finish install when run the installer NOT in silent mode.
58+
* @default true
59+
*/
60+
autoRunAppAfterInstall = true
61+
5662
/**
5763
* *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`.
5864
*
@@ -513,7 +519,8 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
513519
* This is different from the normal quit event sequence.
514520
*
515521
* @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.
516-
* @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.
522+
* @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.
523+
* Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).
517524
*/
518525
abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void
519526

packages/electron-updater/src/BaseUpdater.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export abstract class BaseUpdater extends AppUpdater {
1212

1313
quitAndInstall(isSilent = false, isForceRunAfter = false): void {
1414
this._logger.info(`Install on explicit quitAndInstall`)
15-
const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : true)
15+
// If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app
16+
const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)
1617
if (isInstalled) {
1718
setImmediate(() => {
1819
// this event is normally emitted when calling quitAndInstall, this emulates that

0 commit comments

Comments
 (0)