kopia lustrzana https://github.com/badgen/badgen.net
Handle api exceptions in codecov, github, and npm
rodzic
5d624cbb2e
commit
df3a6be9d8
|
@ -40,6 +40,14 @@ async function handler ({ vcs, owner, repo, branch }: Args) {
|
|||
const endpoint = `https://codecov.io/api/${args.join('/')}`
|
||||
const data = await got(endpoint).then(res => res.body)
|
||||
|
||||
if (!data.commit) {
|
||||
return {
|
||||
subject: 'codecov',
|
||||
status: 'unknown',
|
||||
color: 'grey'
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
subject: 'coverage',
|
||||
status: coverage(data.commit.totals.c),
|
||||
|
|
|
@ -265,7 +265,7 @@ const makeRepoQuery = (topic, owner, repo, restArgs) => {
|
|||
}
|
||||
`
|
||||
|
||||
return queryGithub(query).then(res => res.data.repository)
|
||||
return queryGithub(query).then(res => res.data!.repository)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ const download = async (period, npmName, tag = 'latest') => {
|
|||
|
||||
const { downloads } = await got(endpoint.join('/')).then(
|
||||
res => res.body,
|
||||
err => err.response.statusCode === 404 && { downloads: 0 }
|
||||
err => err.response!.statusCode === 404 && { downloads: 0 }
|
||||
)
|
||||
|
||||
const count = typeof downloads === 'number'
|
||||
|
|
Ładowanie…
Reference in New Issue