fix(GitHubDownloads): type error on latest with pre-downloads (#4030)
This commit is contained in:
committed by
repo-ranger[bot]
parent
9fe4d739b0
commit
76b2e2634a
@@ -191,6 +191,11 @@ module.exports = class GithubDownloads extends GithubAuthV3Service {
|
||||
options: { qs: { per_page: 1 } },
|
||||
errorMessages: errorMessagesFor('repo not found'),
|
||||
})
|
||||
// Note that the API will return an empty array if there are no releases
|
||||
// https://github.com/badges/shields/issues/3786
|
||||
if (!latestReleaseIncludingPrereleases) {
|
||||
throw new NotFound({ prettyMessage: 'no releases' })
|
||||
}
|
||||
releases = [latestReleaseIncludingPrereleases]
|
||||
} else if (tag) {
|
||||
const wantedRelease = await this._requestJson({
|
||||
|
||||
@@ -32,6 +32,11 @@ t.create('downloads-pre for latest release')
|
||||
.get('/downloads-pre/photonstorm/phaser/latest/total.json')
|
||||
.expectBadge({ label: 'downloads@latest', message: isMetric })
|
||||
|
||||
// https://github.com/badges/shields/issues/3786
|
||||
t.create('downloads-pre for latest release (no-releases)')
|
||||
.get('/downloads-pre/badges/shields/latest/total.json')
|
||||
.expectBadge({ label: 'downloads', message: 'no releases' })
|
||||
|
||||
t.create('downloads for release without slash')
|
||||
.get('/downloads/atom/atom/v0.190.0/total.json')
|
||||
.expectBadge({ label: 'downloads@v0.190.0', message: isMetric })
|
||||
|
||||
Reference in New Issue
Block a user