Skip to content

Commit

Permalink
fix(auto-updater): Autoupdates to lower version with allowPrerelease=…
Browse files Browse the repository at this point in the history
…true using GitHub releases

Close #1497
  • Loading branch information
develar committed Apr 24, 2017
1 parent d6f0c57 commit 36fc3db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Auto Update.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do
| --- | --- | --- |
| autoDownload = <code>true</code>| <code>boolean</code> | <a name="AppUpdater-autoDownload"></a>Whether to automatically download an update when it is found. |
| allowPrerelease| <code>boolean</code> | <a name="AppUpdater-allowPrerelease"></a>*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`.<br><br>If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). |
| allowDowngrade| <code>boolean</code> | <a name="AppUpdater-allowDowngrade"></a>Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`. |
| allowDowngrade| <code>boolean</code> | <a name="AppUpdater-allowDowngrade"></a>Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). |
| requestHeaders| <code>[RequestHeaders](electron-builder-http#RequestHeaders)</code> \| <code>null</code> | <a name="AppUpdater-requestHeaders"></a>The request headers. |
| logger = <code>(&lt;any&gt;global).__test_app ? null : console</code>| <code>[Logger](#Logger)</code> \| <code>null</code> | <a name="AppUpdater-logger"></a>The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`. Set it to `null` if you would like to disable a logging feature. |
| signals = <code>new UpdaterSignal(this)</code>| <code>[UpdaterSignal](#UpdaterSignal)</code> | <a name="AppUpdater-signals"></a>For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})` |
Expand Down
5 changes: 2 additions & 3 deletions packages/electron-updater/src/AppUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export abstract class AppUpdater extends EventEmitter {

/**
* Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).
* Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.
* @default false
*/
allowDowngrade = false

Expand Down Expand Up @@ -117,8 +117,7 @@ export abstract class AppUpdater extends EventEmitter {
throw new Error(`App version is not valid semver version: "${currentVersionString}`)
}

this.allowDowngrade = hasPrereleaseComponents(this.currentVersion)
this.allowPrerelease = this.allowDowngrade
this.allowPrerelease = hasPrereleaseComponents(this.currentVersion)

if (options != null) {
this.setFeedURL(options)
Expand Down
1 change: 1 addition & 0 deletions test/src/nsisUpdaterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test("check updates - no versions at all", async () => {

async function testUpdateFromBintray(app: any) {
const updater = new NsisUpdater(null, app)
updater.allowDowngrade = true
updater.updateConfigPath = await writeUpdateConfig(<BintrayOptions>{
provider: "bintray",
owner: "actperepo",
Expand Down

0 comments on commit 36fc3db

Please sign in to comment.