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 de95640 commit 4bd40f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/install.js
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

1 comment on commit 4bd40f5

@kyaw493
Copy link

@kyaw493 kyaw493 commented on 4bd40f5 Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.