Skip to content

Commit 3868af0

Browse files
committed
update README & npm run all
1 parent 56422b6 commit 3868af0

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- name: install dependencies
1414
run: npm ci
15-
- uses: oke-py/npm-audit-action@v1.5.2
15+
- uses: oke-py/npm-audit-action@v1.6.0
1616
with:
1717
github_token: ${{ secrets.GITHUB_TOKEN }}
1818
issue_assignees: oke-py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- uses: actions/checkout@v2
5959
- name: install dependencies
6060
run: npm ci
61-
- uses: oke-py/npm-audit-action@v1.5.2
61+
- uses: oke-py/npm-audit-action@v1.6.0
6262
with:
6363
audit_level: moderate
6464
github_token: ${{ secrets.GITHUB_TOKEN }}

dist/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,13 @@ class Audit {
556556
this.stdout = '';
557557
this.status = null;
558558
}
559-
run(auditLevel) {
559+
run(auditLevel, productionFlag) {
560560
try {
561-
const result = child_process_1.spawnSync('npm', ['audit', '--audit-level', auditLevel], {
561+
const auditOptions = ['audit', '--audit-level', auditLevel];
562+
if (productionFlag === 'true') {
563+
auditOptions.push('--production');
564+
}
565+
const result = child_process_1.spawnSync('npm', auditOptions, {
562566
encoding: 'utf-8',
563567
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
564568
});
@@ -1427,9 +1431,13 @@ function run() {
14271431
if (!['critical', 'high', 'moderate', 'low'].includes(auditLevel)) {
14281432
throw new Error('Invalid input: audit_level');
14291433
}
1434+
const productionFlag = core.getInput('production_flag', { required: false });
1435+
if (!['true', 'false'].includes(productionFlag)) {
1436+
throw new Error('Invalid input: production_flag');
1437+
}
14301438
// run `npm audit`
14311439
const audit = new audit_1.Audit();
1432-
audit.run(auditLevel);
1440+
audit.run(auditLevel, productionFlag);
14331441
core.info(audit.stdout);
14341442
if (audit.foundVulnerability()) {
14351443
// vulnerabilities are found

src/audit.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,16 @@ export class Audit {
99

1010
public run(auditLevel: string, productionFlag: string): void {
1111
try {
12-
const auditOptions: Array<string> =['audit', '--audit-level', auditLevel];
13-
14-
if(productionFlag === 'true') {
15-
auditOptions.push('--production');
12+
const auditOptions: Array<string> = ['audit', '--audit-level', auditLevel]
13+
14+
if (productionFlag === 'true') {
15+
auditOptions.push('--production')
1616
}
1717

18-
const result: SpawnSyncReturns<string> = spawnSync(
19-
'npm',
20-
auditOptions,
21-
{
22-
encoding: 'utf-8',
23-
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
24-
}
25-
)
18+
const result: SpawnSyncReturns<string> = spawnSync('npm', auditOptions, {
19+
encoding: 'utf-8',
20+
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
21+
})
2622

2723
if (result.error) {
2824
throw result.error

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function run(): Promise<void> {
2525
throw new Error('Invalid input: audit_level')
2626
}
2727

28-
const productionFlag = core.getInput('production_flag', {required: false});
28+
const productionFlag = core.getInput('production_flag', {required: false})
2929
if (!['true', 'false'].includes(productionFlag)) {
3030
throw new Error('Invalid input: production_flag')
3131
}

0 commit comments

Comments
 (0)