diff --git a/.changeset/wild-crews-eat.md b/.changeset/wild-crews-eat.md new file mode 100644 index 0000000000..b0a4ba2aad --- /dev/null +++ b/.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 diff --git a/docs/api/electron-builder.md b/docs/api/electron-builder.md index 59bed7bc81..3f69764cb2 100644 --- a/docs/api/electron-builder.md +++ b/docs/api/electron-builder.md @@ -1600,6 +1600,9 @@ return path.join(target.outDir, __${target.name}-${getArtifactArchName(arc

Currently false to prevent breaking the current API, but it should be changed to default true at some point that breaking changes are allowed.

  • +

    forceDevUpdateConfig = false Boolean - 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")

    +
  • +
  • currentVersion SemVer - The current application version.

  • diff --git a/packages/electron-updater/src/AppUpdater.ts b/packages/electron-updater/src/AppUpdater.ts index cf65eb0717..a3afa1299a 100644 --- a/packages/electron-updater/src/AppUpdater.ts +++ b/packages/electron-updater/src/AppUpdater.ts @@ -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. */ @@ -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