Catch errors thrown by Audit.run and increase child process buffer size (#67)
* Audit.run does not need to be async * Set max buffer size for npm audit subprocess to 10MiB
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
import {spawnSync, SpawnSyncReturns} from 'child_process'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
|
||||
const SPAWN_PROCESS_BUFFER_SIZE = 10485760 // 10MiB
|
||||
|
||||
export class Audit {
|
||||
stdout = ''
|
||||
private status: number | null = null
|
||||
|
||||
public async run(auditLevel: string): Promise<void> {
|
||||
public run(auditLevel: string): void {
|
||||
try {
|
||||
const result: SpawnSyncReturns<string> = spawnSync(
|
||||
'npm',
|
||||
['audit', '--audit-level', auditLevel],
|
||||
{
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user