Browse Source

Handle api exceptions in codecov, github, and npm

docker-size
Amio 5 years ago
parent
commit
df3a6be9d8
  1. 8
      endpoints/codecov.ts
  2. 2
      endpoints/github.ts
  3. 2
      endpoints/npm.ts

8
endpoints/codecov.ts

@ -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),

2
endpoints/github.ts

@ -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)
}
}

2
endpoints/npm.ts

@ -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'

Loading…
Cancel
Save