Skip to content

Commit

Permalink
install: Prevent blowing up on audit malformed response (#42)
Browse files Browse the repository at this point in the history
PR-URL: #42
Credit: @framp
Reviewed-By: @zkat
  • Loading branch information
framp authored and zkat committed Aug 20, 2018
1 parent e2c4aea commit 8d1b322
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ Installer.prototype.printInstalled = function (cb) {
if (!this.auditSubmission) return
return Bluebird.resolve(this.auditSubmission).timeout(10000).catch(() => null)
}).then((auditResult) => {
if (auditResult && !auditResult.metadata) {
log.warn('audit', 'Audit result from registry missing metadata. This is probably an issue with the registry.')
}
// maybe write audit report w/ hash of pjson & shrinkwrap for later reading by `npm audit`
if (npm.config.get('json')) {
return this.printInstalledForJSON(diffs, auditResult)
Expand Down Expand Up @@ -834,7 +837,7 @@ Installer.prototype.printInstalledForHuman = function (diffs, auditResult) {
if (removed) actions.push('removed ' + packages(removed))
if (updated) actions.push('updated ' + packages(updated))
if (moved) actions.push('moved ' + packages(moved))
if (auditResult && auditResult.metadata.totalDependencies) {
if (auditResult && auditResult.metadata && auditResult.metadata.totalDependencies) {
actions.push('audited ' + packages(auditResult.metadata.totalDependencies))
}
if (actions.length === 0) {
Expand Down

0 comments on commit 8d1b322

Please sign in to comment.