src/utils/parse.js
function readFiles(
  glob,
  { parsers = {}, encoding = 'utf-8', globOpts = {} } = {}
) {
  return getFiles(glob, globOpts).then(paths => {
    return Promise.all(
      paths.map(filepath => {
        return readFile(filepath, encoding).then(fileData => {
          const parser = matchParser(filepath, parsers);
          fileData = parser(fileData, filepath);
          if (typeof fileData === 'string') {
            fileData = { contents: fileData };
          }
          return Object.assign(fileData, { path: filepath });
        });
      })
    );
  });
}
function readFiles(
  glob,
  { parsers = {}, encoding = 'utf-8', globOpts = {} } = {}
) {
  return getFiles(glob, globOpts).then(paths => {
    return Promise.all(
      paths.map(filepath => {
        return readFile(filepath, encoding).then(fileData => {
          const parser = matchParser(filepath, parsers);
          fileData = parser(fileData, filepath);
          if (typeof fileData === 'string') {
            fileData = { contents: fileData };
          }
          return Object.assign(fileData, { path: filepath });
        });
      })
    );
  });
}
function readFiles ( glob , { parsers = { } , encoding = 'utf-8' , globOpts = { } } = { } ) { return getFiles ( glob , globOpts ) . then ( paths => { return Promise . all ( paths . map ( filepath => { return readFile ( filepath , encoding ) . then ( fileData => { const parser = matchParser ( filepath , parsers ) ; fileData = parser ( fileData , filepath ) ; if ( typeof fileData === 'string' ) { fileData = { contents : fileData } ; } return Object . assign ( fileData , { path : filepath } ) ; } ) ; } ) ) ; } ) ; }
Take a glob; read the files, optionally running a `contentFn` over
the contents of the file.

@param {glob} glob of files to read
@param {Object} Options:
- {Object} available parsers
- {String} encoding
- {Object} globOpts gets passed to getFiles
@return {Promise} resolving to Array of Objects:
- {String} path
- {String|Mixed} contents: contents of file after contentFn
Take a glob ; read the files optionally running a contentFn over the contents of the file .