run npm run all

This commit is contained in:
Naoki Oketani
2020-12-12 12:01:55 +00:00
parent c4cd169835
commit 8851061b81
3 changed files with 10 additions and 6 deletions

7
dist/index.js vendored
View File

@@ -563,8 +563,8 @@ class Audit {
auditOptions.push('--production');
}
if (jsonFlag === 'true') {
auditOptions.push('--json');
}
auditOptions.push('--json');
}
const result = child_process_1.spawnSync('npm', auditOptions, {
encoding: 'utf-8',
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
@@ -1444,8 +1444,9 @@ function run() {
}
// run `npm audit`
const audit = new audit_1.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
// get GitHub information

View File

@@ -7,7 +7,11 @@ export class Audit {
stdout = ''
private status: number | null = null
public run(auditLevel: string, productionFlag: string, jsonFlag: string): void {
public run(
auditLevel: string,
productionFlag: string,
jsonFlag: string
): void {
try {
const auditOptions: Array<string> = ['audit', '--audit-level', auditLevel]

View File

@@ -35,12 +35,11 @@ export async function run(): Promise<void> {
throw new Error('Invalid input: json_flag')
}
// run `npm audit`
const audit = new Audit()
audit.run(auditLevel, productionFlag, jsonFlag)
core.info(audit.stdout)
core.setOutput('npm_audit', audit.stdout);
core.setOutput('npm_audit', audit.stdout)
if (audit.foundVulnerability()) {
// vulnerabilities are found