Skip to content

Commit

Permalink
fix(auto-updater): respect vPrefixedTagName for auto update
Browse files Browse the repository at this point in the history
Close #1417
  • Loading branch information
develar committed Mar 29, 2017
1 parent 1affc61 commit 624311b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/electron-builder/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export function computeDownloadUrl(publishConfig: PublishConfiguration, fileName
}
else {
const gh = <GithubOptions>publishConfig
baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/v${packager.appInfo.version}`
baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/${gh.vPrefixedTagName === false ? "" : "v"}${packager.appInfo.version}`
}

if (fileName == null) {
Expand Down
10 changes: 7 additions & 3 deletions packages/electron-updater/src/GitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class GitHubProvider extends BaseGitHubProvider<UpdateInfo> {
const version = await this.getLatestVersionString(basePath, cancellationToken)
let result: any
const channelFile = getChannelFilename(getDefaultChannelName())
const requestOptions = Object.assign({path: `${basePath}/download/v${version}/${channelFile}`, headers: this.requestHeaders || undefined}, this.baseUrl)
const requestOptions = Object.assign({path: this.getBaseDownloadPath(version, channelFile), headers: this.requestHeaders || undefined}, this.baseUrl)
try {
result = await request<UpdateInfo>(requestOptions, cancellationToken)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ export class GitHubProvider extends BaseGitHubProvider<UpdateInfo> {
}
}

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

Expand All @@ -80,10 +80,14 @@ export class GitHubProvider extends BaseGitHubProvider<UpdateInfo> {
const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-")
return {
name: name,
url: formatUrl(Object.assign({path: `${this.basePath}/download/v${versionInfo.version}/${name}`}, this.baseUrl)),
url: formatUrl(Object.assign({path: this.getBaseDownloadPath(versionInfo.version, name)}, this.baseUrl)),
sha2: versionInfo.sha2,
}
}

private getBaseDownloadPath(version: string, fileName: string) {
return `${this.basePath}/download/${this.options.vPrefixedTagName === false ? "" : "v"}${version}/${fileName}`
}
}

interface GithubReleaseInfo {
Expand Down

0 comments on commit 624311b

Please sign in to comment.