Skip to content

Commit 7d43ddf

Browse files
committed
audit: Exit with non-zero when vulnerabilities are found
Credit: @iarna
1 parent 113e1a3 commit 7d43ddf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/audit.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ function auditCmd (args, cb) {
7878
}
7979
throw err
8080
}).then((auditResult) => {
81+
const vulns =
82+
auditResult.metadata.vulnerabilities.low +
83+
auditResult.metadata.vulnerabilities.moderate +
84+
auditResult.metadata.vulnerabilities.high +
85+
auditResult.metadata.vulnerabilities.critical
86+
if (vulns > 0) process.exitCode = 1
8187
return audit.printFullReport(auditResult)
8288
}).asCallback(cb)
8389
}

0 commit comments

Comments
 (0)