bin/src/cli-main.js
function processArgs(args, files = []) {
  return args.reduce((acc, arg) => {
    let stats;
    try {
      stats = fs.statSync(arg);
    } catch (err) {
      // Do nothing
    }

    // If argument is a directory, process the files inside
    if (stats && stats.isDirectory()) {
      return processArgs(
        fs.readdirSync(arg).map(file => path.join(arg, file)),
        files
      );
    }

    // If `statSync` failed, validating will handle the error
    // If the argument is a file, check if its a JSON file before validating
    if (!stats || JsonFileRegex.test(arg)) {
      acc.push(validateFile(arg));
    }

    return acc;
  }, files);
}
function processArgs(args, files = []) {
  return args.reduce((acc, arg) => {
    let stats;
    try {
      stats = fs.statSync(arg);
    } catch (err) {
      // Do nothing
    }

    // If argument is a directory, process the files inside
    if (stats && stats.isDirectory()) {
      return processArgs(
        fs.readdirSync(arg).map(file => path.join(arg, file)),
        files
      );
    }

    // If `statSync` failed, validating will handle the error
    // If the argument is a file, check if its a JSON file before validating
    if (!stats || JsonFileRegex.test(arg)) {
      acc.push(validateFile(arg));
    }

    return acc;
  }, files);
}
function processArgs ( args , files = [ ] ) { return args . reduce ( ( acc , arg ) => { let stats ; try { stats = fs . statSync ( arg ) ; } catch ( err ) { // Do nothing } // If argument is a directory, process the files inside if ( stats && stats . isDirectory ( ) ) { return processArgs ( fs . readdirSync ( arg ) . map ( file => path . join ( arg , file ) ) , files ) ; } // If `statSync` failed, validating will handle the error // If the argument is a file, check if its a JSON file before validating if ( ! stats || JsonFileRegex . test ( arg ) ) { acc . push ( validateFile ( arg ) ) ; } return acc ; } , files ) ; }
Process arguments, recursing through any directories,
to find and validate JSON files

@param {array} args Array of paths
@param {array} files Array to populate

@return {array} File objects to be processed
Process arguments recursing through any directories to find and validate JSON files