src/index.js
function getData (allFiles = [], config) {
  const files = allFiles.reduce((memo, iteratee) => {
    const filePath = path.parse(iteratee)
    if (config.include.includes(filePath.ext) && !config.exclude.includes(filePath.base)) {
      const newFile = {
        file: iteratee.replace(config.content, ''),
        dir: filePath.dir.replace(config.content, ''),
        name: filePath.name,
        base: filePath.base,
        ext: filePath.ext,
      }
      if (filePath.ext === '.md') {
        const file = fs.readFileSync(iteratee, { encoding: 'utf8' })
        const frontMatter = fm(file)
        newFile.attr = frontMatter.attributes
        newFile.body = frontMatter.body
      } else if (filePath.ext === '.png') {
        const image = new PNG.load(iteratee)
        newFile.width = image.width
        newFile.height = image.height
      }
      memo.push(newFile)
    }
    return memo
  }, [])
  return files
}
function getData (allFiles = [], config) {
  const files = allFiles.reduce((memo, iteratee) => {
    const filePath = path.parse(iteratee)
    if (config.include.includes(filePath.ext) && !config.exclude.includes(filePath.base)) {
      const newFile = {
        file: iteratee.replace(config.content, ''),
        dir: filePath.dir.replace(config.content, ''),
        name: filePath.name,
        base: filePath.base,
        ext: filePath.ext,
      }
      if (filePath.ext === '.md') {
        const file = fs.readFileSync(iteratee, { encoding: 'utf8' })
        const frontMatter = fm(file)
        newFile.attr = frontMatter.attributes
        newFile.body = frontMatter.body
      } else if (filePath.ext === '.png') {
        const image = new PNG.load(iteratee)
        newFile.width = image.width
        newFile.height = image.height
      }
      memo.push(newFile)
    }
    return memo
  }, [])
  return files
}
function getData ( allFiles = [ ] , config ) { const files = allFiles . reduce ( ( memo , iteratee ) => { const filePath = path . parse ( iteratee ) if ( config . include . includes ( filePath . ext ) && ! config . exclude . includes ( filePath . base ) ) { const newFile = { file : iteratee . replace ( config . content , '' ) , dir : filePath . dir . replace ( config . content , '' ) , name : filePath . name , base : filePath . base , ext : filePath . ext , } if ( filePath . ext === '.md' ) { const file = fs . readFileSync ( iteratee , { encoding : 'utf8' } ) const frontMatter = fm ( file ) newFile . attr = frontMatter . attributes newFile . body = frontMatter . body } else if ( filePath . ext === '.png' ) { const image = new PNG . load ( iteratee ) newFile . width = image . width newFile . height = image . height } memo . push ( newFile ) } return memo } , [ ] ) return files }
Get data from list of files filtered based on options
@param  {Array}  allFiles List of files and directories
@return {Array}           Updated list of files with content
Get data from list of files filtered based on options