Skip to content

Commit

Permalink
feat(electron-updater): find installer exe in bintray artifacts not s…
Browse files Browse the repository at this point in the history
…o strict

Close #1305
  • Loading branch information
develar committed Feb 28, 2017
1 parent f4398a7 commit 9ac818f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/electron-updater/src/BintrayProvider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Provider, FileInfo } from "./api"
import { BintrayClient } from "electron-builder-http/out/bintray"
import { BintrayOptions, VersionInfo } from "electron-builder-http/out/publishOptions"
import { HttpError } from "electron-builder-http"
import { BintrayClient } from "electron-builder-http/out/bintray"
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
import { BintrayOptions, VersionInfo } from "electron-builder-http/out/publishOptions"
import { FileInfo, Provider } from "./api"

export class BintrayProvider extends Provider<VersionInfo> {
private client: BintrayClient
Expand Down Expand Up @@ -32,18 +32,17 @@ export class BintrayProvider extends Provider<VersionInfo> {
try {
const files = await this.client.getVersionFiles(versionInfo.version)
const suffix = `${versionInfo.version}.exe`
for (const file of files) {
if (file.name.endsWith(suffix) && file.name.includes("Setup")) {
return {
name: file.name,
url: `https://dl.bintray.com/${this.client.owner}/${this.client.repo}/${file.name}`,
sha2: file.sha256,
}
}
const file = files.find(it => it.name.endsWith(suffix) && it.name.includes("Setup")) || files.find(it => it.name.endsWith(suffix)) || files.find(it => it.name.endsWith(".exe"))
if (file == null) {
//noinspection ExceptionCaughtLocallyJS
throw new Error(`Cannot find suitable file for version ${versionInfo.version} in: ${JSON.stringify(files, null, 2)}`)
}

//noinspection ExceptionCaughtLocallyJS
throw new Error(`Cannot find suitable file for version ${versionInfo.version} in: ${JSON.stringify(files, null, 2)}`)
return {
name: file.name,
url: `https://dl.bintray.com/${this.client.owner}/${this.client.repo}/${file.name}`,
sha2: file.sha256,
}
}
catch (e) {
if (e instanceof HttpError && e.response.statusCode === 404) {
Expand Down

0 comments on commit 9ac818f

Please sign in to comment.