Skip to content

Commit

Permalink
feat(electron-updater): NSIS autoUpdater.setFeedURL throws error
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jan 21, 2017
1 parent 3dd87da commit eb6a453
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 128 deletions.
6 changes: 3 additions & 3 deletions docs/Auto Update.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ The `autoUpdater` object has the following methods:
### `autoUpdater.setFeedURL(options)`
* `options` GenericServerOptions | BintrayOptions | GithubOptions — if you want to override configuration in the `app-update.yml`.
* `options` GenericServerOptions | BintrayOptions | GithubOptions | string — if you want to override configuration in the `app-update.yml`.
Sets the `options`. Windows-only for now. On macOS please refer [electron setFeedURL reference](https://github.com/electron/electron/blob/master/docs/api/auto-updater.md#autoupdatersetfeedurlurl-requestheaders).
Sets the `options`. If value is `string`, `GenericServerOptions` will be set with value as `url`.
### `autoUpdater.checkForUpdates(): Promise<UpdateCheckResult>`
Asks the server whether there is an update. On macOS you must call `setFeedURL` before using this API.
Asks the server whether there is an update.
### `autoUpdater.quitAndInstall()`
Expand Down
16 changes: 12 additions & 4 deletions packages/electron-updater/src/AppUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,16 @@ export abstract class AppUpdater extends EventEmitter {
return "Deprecated. Do not use it."
}

setFeedURL(value: PublishConfiguration | BintrayOptions | GithubOptions | GenericServerOptions) {
this.clientPromise = BluebirdPromise.resolve(createClient(value))
setFeedURL(value: PublishConfiguration | BintrayOptions | GithubOptions | GenericServerOptions | string) {
// https://github.com/electron-userland/electron-builder/issues/1105
let client: Provider<any>
if (typeof value === "string") {
client = new GenericProvider({provider: "generic", url: value})
}
else {
client = createClient(value)
}
this.clientPromise = BluebirdPromise.resolve(client)
}

checkForUpdates(): Promise<UpdateCheckResult> {
Expand Down Expand Up @@ -118,7 +126,7 @@ export abstract class AppUpdater extends EventEmitter {
this.emit("checking-for-update")
try {
if (this.clientPromise == null) {
this.clientPromise = loadUpdateConfig()
this.clientPromise = loadUpdateConfig().then(it => createClient(it))
}
return await this.doCheckForUpdates()
}
Expand Down Expand Up @@ -205,7 +213,7 @@ export abstract class AppUpdater extends EventEmitter {
}

async function loadUpdateConfig() {
return createClient(safeLoad(await readFile(path.join((<any>global).__test_resourcesPath || (<any>process).resourcesPath, "app-update.yml"), "utf-8")))
return safeLoad(await readFile(path.join((<any>global).__test_resourcesPath || (<any>process).resourcesPath, "app-update.yml"), "utf-8"))
}

function createClient(data: string | PublishConfiguration | BintrayOptions | GithubOptions) {
Expand Down
Loading

0 comments on commit eb6a453

Please sign in to comment.