Browse Source

Merge branch 'handle-private-packages' of https://github.com/21echoes/thanks into 21echoes-handle-private-packages

master
Feross Aboukhadijeh 7 years ago
parent
commit
9257aa5894
  1. 19
      src/cmd.js

19
src/cmd.js

@ -213,7 +213,12 @@ async function fetchPkg (client, pkgName) {
staleOk: true,
auth: registryAuthToken()
}
return client.getAsync(url, opts)
try {
return await client.getAsync(url, opts)
} catch (err) {
console.error(chalk`\n{red error fetching}`, pkgName, err)
return {}
}
}
function printTable (authorsSeeking, pkgNamesSeeking, authorsPkgNames, directPkgNames) {
@ -281,14 +286,20 @@ async function bulkFetchPkgDownloads (pkgNames) {
const url = DOWNLOADS_URL + pkgNamesSubset.join(',')
const res = await got(url, { json: true })
Object.keys(res.body).forEach(pkgName => {
pkgDownloads[pkgName] = res.body[pkgName].downloads
if (res.body[pkgName]) {
pkgDownloads[pkgName] = res.body[pkgName].downloads
}
})
}
await Promise.all(scopedPkgNames.map(async scopedPkgName => {
const url = DOWNLOADS_URL + scopedPkgName
const res = await got(url, { json: true })
pkgDownloads[scopedPkgName] = res.body.downloads
try {
const res = await got(url, { json: true })
pkgDownloads[scopedPkgName] = res.body.downloads
} catch (err) {
console.error(chalk`\n{red error fetching}`, scopedPkgName, err)
}
}))
return pkgDownloads

Loading…
Cancel
Save