Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow dev update config to be forced for testing auto-updater flow #7117

Merged
merged 3 commits into from Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-crews-eat.md
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

feat: allow dev update config to be forced for testing auto-updater flow
3 changes: 3 additions & 0 deletions docs/api/electron-builder.md
Expand Up @@ -1600,6 +1600,9 @@ return path.join(target.outDir, <code>__${target.name}-${getArtifactArchName(arc
<p>Currently false to prevent breaking the current API, but it should be changed to default true at some point that breaking changes are allowed.</p>
</li>
<li>
<p><code id="AppUpdater-forceDevUpdateConfig">forceDevUpdateConfig</code> = <code>false</code> Boolean - Allows developer to force the updater to work in “dev” mode, looking for “dev-app-update.yml” instead of “app-update.yml” Dev: <code>path.join(this.app.getAppPath(), &quot;dev-app-update.yml&quot;)</code> Prod: <code>path.join(process.resourcesPath!, &quot;app-update.yml&quot;)</code></p>
</li>
<li>
<p><code id="AppUpdater-currentVersion">currentVersion</code> SemVer - The current application version.</p>
</li>
<li>
Expand Down
15 changes: 12 additions & 3 deletions packages/electron-updater/src/AppUpdater.ts
Expand Up @@ -83,9 +83,17 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
*
* @default false
*/

disableWebInstaller = false

/**
* Allows developer to force the updater to work in "dev" mode, looking for "dev-app-update.yml" instead of "app-update.yml"
* Dev: `path.join(this.app.getAppPath(), "dev-app-update.yml")`
* Prod: `path.join(process.resourcesPath!, "app-update.yml")`
*
* @default false
*/
forceDevUpdateConfig = false

/**
* The current application version.
*/
Expand Down Expand Up @@ -279,8 +287,9 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
}

public isUpdaterActive(): boolean {
if (!this.app.isPackaged) {
this._logger.info("Skip checkForUpdatesAndNotify because application is not packed")
const isEnabled = this.app.isPackaged || this.forceDevUpdateConfig
if (!isEnabled) {
this._logger.info("Skip checkForUpdates because application is not packed and dev update config is not forced")
return false
}
return true
Expand Down