Skip to content

Commit 4bd40f5

Browse files
frampzkat
authored andcommitted
install: Prevent blowing up on audit malformed response (#42)
PR-URL: #42 Credit: @framp Reviewed-By: @zkat
1 parent de95640 commit 4bd40f5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/install.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,9 @@ Installer.prototype.printInstalled = function (cb) {
766766
if (!this.auditSubmission) return
767767
return Bluebird.resolve(this.auditSubmission).timeout(10000).catch(() => null)
768768
}).then((auditResult) => {
769+
if (auditResult && !auditResult.metadata) {
770+
log.warn('audit', 'Audit result from registry missing metadata. This is probably an issue with the registry.')
771+
}
769772
// maybe write audit report w/ hash of pjson & shrinkwrap for later reading by `npm audit`
770773
if (npm.config.get('json')) {
771774
return this.printInstalledForJSON(diffs, auditResult)
@@ -834,7 +837,7 @@ Installer.prototype.printInstalledForHuman = function (diffs, auditResult) {
834837
if (removed) actions.push('removed ' + packages(removed))
835838
if (updated) actions.push('updated ' + packages(updated))
836839
if (moved) actions.push('moved ' + packages(moved))
837-
if (auditResult && auditResult.metadata.totalDependencies) {
840+
if (auditResult && auditResult.metadata && auditResult.metadata.totalDependencies) {
838841
actions.push('audited ' + packages(auditResult.metadata.totalDependencies))
839842
}
840843
if (actions.length === 0) {

0 commit comments

Comments
 (0)