Skip to content

Commit

Permalink
fix(electron-updater): PrivateGitHubProvider — Github Enterprise support
Browse files Browse the repository at this point in the history
Close #2038
  • Loading branch information
rain authored and develar committed Sep 6, 2017
1 parent 41935d8 commit becf9b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/electron-updater/src/GitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export abstract class BaseGitHubProvider<T extends UpdateInfo> extends Provider<

this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
}

protected computeGithubBasePath(result: string) {
// https://github.com/electron-userland/electron-builder/issues/1903#issuecomment-320881211
const host = this.options.host
return host != null && host !== "github.com" && host !== "api.github.com" ? `/api/v3${result}` : result
}
}

export class GitHubProvider extends BaseGitHubProvider<UpdateInfo> {
Expand Down Expand Up @@ -109,10 +115,7 @@ export class GitHubProvider extends BaseGitHubProvider<UpdateInfo> {
}

private get basePath() {
const result = `/${this.options.owner}/${this.options.repo}/releases`
// https://github.com/electron-userland/electron-builder/issues/1903#issuecomment-320881211
const host = this.options.host
return host != null && host !== "github.com" && host !== "api.github.com" ? `/api/v3${result}` : result
return this.computeGithubBasePath(`/${this.options.owner}/${this.options.repo}/releases`)
}

async getUpdateFile(versionInfo: UpdateInfo): Promise<FileInfo> {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-updater/src/PrivateGitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PrivateGitHubProvider extends BaseGitHubProvider<PrivateGitHubUpdat
}

private get basePath() {
return `/repos/${this.options.owner}/${this.options.repo}/releases`
return this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`)
}

async getUpdateFile(versionInfo: PrivateGitHubUpdateInfo): Promise<FileInfo> {
Expand Down

0 comments on commit becf9b4

Please sign in to comment.