audit.js
function exitHandler(options, err) {
  if (err) {
    if (err.stack) {
      console.error(err.stack);
    } else {
      console.error(err.toString());
    }
  }
	if (whitelistedVulnerabilities.length > 0) {
        logger.info(colors.bold.yellow("Filtering the following vulnerabilities"));
        logger.info(colors.bold.yellow('=================================================='));
        for (var i = 0; i < whitelistedVulnerabilities.length; i++) {
        	var detail = whitelistedVulnerabilities[i];
          logger.info(`${colors.bold.blue(detail['title'])} affected versions: ${colors.red(detail['package'])} ${colors.red(detail['versions'])}`);
          logger.info(`${detail['description']}`);
          logger.info(colors.bold("ID") + ": " + detail.id);
          if (detail.whitelistedPaths) {
            detail.whitelistedPaths.forEach(function(path) {
              logger.info(colors.bold("Ignored Path") + ": " + path);
            })
          }
          logger.info(colors.bold.yellow('=================================================='));
        };
	}

  logger.info('');
  logger.info('Audited dependencies: ' + actualAudits +
            ', Vulnerable: ' + colors.bold.red(vulnerabilityCount) +
            ', Ignored: ' + whitelistedVulnerabilities.length);

    if(config.get('report')) {
        var filtered = whitelistedVulnerabilities.length;
        mkdirp('reports');
        if (JUnit[0] != '<') { // This is a hack in case this gets called twice
        	// Convert to XML
            JUnit = jsontoxml(JUnit);
        }
        var dom = new DOMParser().parseFromString(JUnit);
        dom.documentElement.setAttribute('name', `auditjs.security.${programPackage.split('.')[0]}`);
        dom.documentElement.setAttribute('errors', 0);
        dom.documentElement.setAttribute('tests', expectedAudits);
        dom.documentElement.setAttribute('package', 'test');
        dom.documentElement.setAttribute('id', '');
        dom.documentElement.setAttribute('skipped', filtered);
        dom.documentElement.setAttribute('failures', vulnerabilityCount);
        JUnit = new XMLSerializer().serializeToString(dom);
        logger.info( `Wrote JUnit report to reports/${output}`);
        fs.writeFileSync('reports/' + output, `<?xml version="1.0" encoding="UTF-8"?>\n${JUnit}`);
    }

    if (config.get('suppressExitError')) {
      process.exit(0);
    } else {
      process.exit(vulnerabilityCount);
    }
}
function exitHandler(options, err) {
  if (err) {
    if (err.stack) {
      console.error(err.stack);
    } else {
      console.error(err.toString());
    }
  }
	if (whitelistedVulnerabilities.length > 0) {
        logger.info(colors.bold.yellow("Filtering the following vulnerabilities"));
        logger.info(colors.bold.yellow('=================================================='));
        for (var i = 0; i < whitelistedVulnerabilities.length; i++) {
        	var detail = whitelistedVulnerabilities[i];
          logger.info(`${colors.bold.blue(detail['title'])} affected versions: ${colors.red(detail['package'])} ${colors.red(detail['versions'])}`);
          logger.info(`${detail['description']}`);
          logger.info(colors.bold("ID") + ": " + detail.id);
          if (detail.whitelistedPaths) {
            detail.whitelistedPaths.forEach(function(path) {
              logger.info(colors.bold("Ignored Path") + ": " + path);
            })
          }
          logger.info(colors.bold.yellow('=================================================='));
        };
	}

  logger.info('');
  logger.info('Audited dependencies: ' + actualAudits +
            ', Vulnerable: ' + colors.bold.red(vulnerabilityCount) +
            ', Ignored: ' + whitelistedVulnerabilities.length);

    if(config.get('report')) {
        var filtered = whitelistedVulnerabilities.length;
        mkdirp('reports');
        if (JUnit[0] != '<') { // This is a hack in case this gets called twice
        	// Convert to XML
            JUnit = jsontoxml(JUnit);
        }
        var dom = new DOMParser().parseFromString(JUnit);
        dom.documentElement.setAttribute('name', `auditjs.security.${programPackage.split('.')[0]}`);
        dom.documentElement.setAttribute('errors', 0);
        dom.documentElement.setAttribute('tests', expectedAudits);
        dom.documentElement.setAttribute('package', 'test');
        dom.documentElement.setAttribute('id', '');
        dom.documentElement.setAttribute('skipped', filtered);
        dom.documentElement.setAttribute('failures', vulnerabilityCount);
        JUnit = new XMLSerializer().serializeToString(dom);
        logger.info( `Wrote JUnit report to reports/${output}`);
        fs.writeFileSync('reports/' + output, `<?xml version="1.0" encoding="UTF-8"?>\n${JUnit}`);
    }

    if (config.get('suppressExitError')) {
      process.exit(0);
    } else {
      process.exit(vulnerabilityCount);
    }
}
function exitHandler ( options , err ) { if ( err ) { if ( err . stack ) { console . error ( err . stack ) ; } else { console . error ( err . toString ( ) ) ; } } if ( whitelistedVulnerabilities . length > 0 ) { logger . info ( colors . bold . yellow ( "Filtering the following vulnerabilities" ) ) ; logger . info ( colors . bold . yellow ( '==================================================' ) ) ; for ( var i = 0 ; i < whitelistedVulnerabilities . length ; i ++ ) { var detail = whitelistedVulnerabilities [ i ] ; logger . info ( ` ${ colors . bold . blue ( detail [ 'title' ] ) } ${ colors . red ( detail [ 'package' ] ) } ${ colors . red ( detail [ 'versions' ] ) } ` ) ; logger . info ( ` ${ detail [ 'description' ] } ` ) ; logger . info ( colors . bold ( "ID" ) + ": " + detail . id ) ; if ( detail . whitelistedPaths ) { detail . whitelistedPaths . forEach ( function ( path ) { logger . info ( colors . bold ( "Ignored Path" ) + ": " + path ) ; } ) } logger . info ( colors . bold . yellow ( '==================================================' ) ) ; } ; } logger . info ( '' ) ; logger . info ( 'Audited dependencies: ' + actualAudits + ', Vulnerable: ' + colors . bold . red ( vulnerabilityCount ) + ', Ignored: ' + whitelistedVulnerabilities . length ) ; if ( config . get ( 'report' ) ) { var filtered = whitelistedVulnerabilities . length ; mkdirp ( 'reports' ) ; if ( JUnit [ 0 ] != '<' ) { // This is a hack in case this gets called twice // Convert to XML JUnit = jsontoxml ( JUnit ) ; } var dom = new DOMParser ( ) . parseFromString ( JUnit ) ; dom . documentElement . setAttribute ( 'name' , ` ${ programPackage . split ( '.' ) [ 0 ] } ` ) ; dom . documentElement . setAttribute ( 'errors' , 0 ) ; dom . documentElement . setAttribute ( 'tests' , expectedAudits ) ; dom . documentElement . setAttribute ( 'package' , 'test' ) ; dom . documentElement . setAttribute ( 'id' , '' ) ; dom . documentElement . setAttribute ( 'skipped' , filtered ) ; dom . documentElement . setAttribute ( 'failures' , vulnerabilityCount ) ; JUnit = new XMLSerializer ( ) . serializeToString ( dom ) ; logger . info ( ` ${ output } ` ) ; fs . writeFileSync ( 'reports/' + output , ` \n ${ JUnit } ` ) ; } if ( config . get ( 'suppressExitError' ) ) { process . exit ( 0 ) ; } else { process . exit ( vulnerabilityCount ) ; } }
Set the return value

@param options
@param err
@returns
Set the return value