fix npm badges when maintainers not in response (#10286)

This commit is contained in:
chris48s
2024-06-26 19:56:17 +01:00
committed by GitHub
parent 5c8129904f
commit 61a6963919
2 changed files with 10 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ const packageDataSchema = Joi.object({
maintainers: Joi.array()
// We don't need the keys here, just the length.
.items(Joi.object({}))
.required(),
.default([]),
types: Joi.string(),
// `typings` is an alias for `types` and often used
// https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package

View File

@@ -16,3 +16,12 @@ t.create('contributor count for unknown package')
label: 'npm collaborators',
message: 'package not found',
})
t.create('contributor count for package package without a maintainers property')
.get('/package-without-maintainers.json')
.intercept(nock =>
nock('https://registry.npmjs.org')
.get('/package-without-maintainers/latest')
.reply(200, {}),
)
.expectBadge({ label: 'npm collaborators', message: '0' })