feat: add the ability to run with '--json' and output the result (#78)

* addition-of-json-flag

* Set output of npn audit
This commit is contained in:
sgkiokas
2020-12-12 13:56:05 +02:00
committed by GitHub
parent 3868af0215
commit c4cd169835
8 changed files with 133 additions and 10 deletions

View File

@@ -30,10 +30,17 @@ export async function run(): Promise<void> {
throw new Error('Invalid input: production_flag')
}
const jsonFlag = core.getInput('json_flag', {required: false})
if (!['true', 'false'].includes(jsonFlag)) {
throw new Error('Invalid input: json_flag')
}
// run `npm audit`
const audit = new Audit()
audit.run(auditLevel, productionFlag)
audit.run(auditLevel, productionFlag, jsonFlag)
core.info(audit.stdout)
core.setOutput('npm_audit', audit.stdout);
if (audit.foundVulnerability()) {
// vulnerabilities are found