import get from 'lodash.get' ; import { AuditLevel , CommandOptions } from 'src/types' ; import { isWholeNumber } from '../utils/common' ; import { readFile } from '../utils/file' ; import { getExceptionsIds } from '../utils/vulnerability' ; param { Object } options param { Function } fn export default function handleInput ( options , fn ) { const auditCommand = [ 'npm audit' , get ( options , 'production' ) ? '--production' : '' , get ( options , 'registry' ) ? `--registry=${ options . registry }` : '' , ] . filter ( Boolean ) . join ( ' ' ) ; const envVar = process . env . NPM_CONFIG_AUDIT_LEVEL as AuditLevel ; const auditLevel = get ( options , 'level' , envVar ) || 'info' ; const nsprc = readFile ( '.nsprc' ) ; const cmdExceptions = get ( options , 'exclude' , '' ) . split ( ',' ) . filter ( isWholeNumber ) . map ( Number ) ; const exceptionIds = getExceptionsIds ( nsprc , cmdExceptions ) ; fn ( auditCommand , auditLevel , exceptionIds ) ; }