feat: add the ability to run with '--production' (#75)
* feat: add the ability to run with '--production' Adding the config options to run npm audit with the --production flag. Contributes to: #74 Signed-off-by: Stelios Gkiokas <s_giokas@hotmail.com> * fix: add tests Adding the relevant tests for the new production flag. Contributes to: #74 Signed-off-by: Stelios Gkiokas <s_giokas@hotmail.com>
This commit is contained in:
10
src/audit.ts
10
src/audit.ts
@@ -7,11 +7,17 @@ export class Audit {
|
||||
stdout = ''
|
||||
private status: number | null = null
|
||||
|
||||
public run(auditLevel: string): void {
|
||||
public run(auditLevel: string, productionFlag: string): void {
|
||||
try {
|
||||
const auditOptions: Array<string> =['audit', '--audit-level', auditLevel];
|
||||
|
||||
if(productionFlag === 'true') {
|
||||
auditOptions.push('--production');
|
||||
}
|
||||
|
||||
const result: SpawnSyncReturns<string> = spawnSync(
|
||||
'npm',
|
||||
['audit', '--audit-level', auditLevel],
|
||||
auditOptions,
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
|
||||
|
||||
Reference in New Issue
Block a user