fix [pypi] status badge when package has no 'Development Status' classifier (#10107)
This commit is contained in:
@@ -28,6 +28,7 @@ export default class PypiStatus extends PypiBase {
|
||||
stable: 'brightgreen',
|
||||
mature: 'brightgreen',
|
||||
inactive: 'red',
|
||||
unknown: 'lightgrey',
|
||||
}[status]
|
||||
|
||||
return {
|
||||
@@ -48,7 +49,7 @@ export default class PypiStatus extends PypiBase {
|
||||
// - Development Status :: 6 - Mature
|
||||
// - Development Status :: 7 - Inactive
|
||||
// https://pypi.org/pypi?%3Aaction=list_classifiers
|
||||
const status = parseClassifiers(
|
||||
let status = parseClassifiers(
|
||||
packageData,
|
||||
/^Development Status :: (\d - \S+)$/,
|
||||
)
|
||||
@@ -57,6 +58,10 @@ export default class PypiStatus extends PypiBase {
|
||||
.map(classifier => classifier.replace(/production\/stable/i, 'stable'))
|
||||
.pop()
|
||||
|
||||
if (!status) {
|
||||
status = 'Unknown'
|
||||
}
|
||||
|
||||
return this.constructor.render({ status })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ t.create('status (valid, beta)')
|
||||
.get('/django/2.0rc1.json')
|
||||
.expectBadge({ label: 'status', message: 'beta' })
|
||||
|
||||
t.create('status (status not specified)')
|
||||
.get('/arcgis2geojson/3.0.2.json')
|
||||
.expectBadge({ label: 'status', message: 'unknown' })
|
||||
|
||||
t.create('status (invalid)')
|
||||
.get('/not-a-package.json')
|
||||
.expectBadge({ label: 'status', message: 'package or version not found' })
|
||||
|
||||
Reference in New Issue
Block a user