diff --git a/src/cmd.js b/src/cmd.js index 482dcdb..70a8591 100755 --- a/src/cmd.js +++ b/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