Skip to content

Commit

Permalink
feat: Allow the AppUpdater to be forced into dev mode, allowing it to…
Browse files Browse the repository at this point in the history
… be activated when the app is not packaged (#7117)
  • Loading branch information
mmaietta committed Sep 2, 2022
1 parent 7d606af commit 0c52841
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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

0 comments on commit 0c52841

Please sign in to comment.