Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Created May 4, 2018 13:21
Show Gist options
  • Save vinicius73/95c502b0d64e28292eefea50d8fcef1f to your computer and use it in GitHub Desktop.
Save vinicius73/95c502b0d64e28292eefea50d8fcef1f to your computer and use it in GitHub Desktop.
const { curry } = require('ramda')
const { readdirSync, readFileSync } = require('fs')
const path = require('path')
const isGraphQLFile = fileName => fileName.endsWith('.graphql')
const readFile = curry((dirname, fileName) => readFileSync(path.join(dirname, fileName), 'utf8'))
/**
* @method loadGraphQLFiles
* @param {String} dirname
* @return {Array<String>}
*/
const loadGraphQLFiles = dirname => readdirSync(dirname)
.filter(isGraphQLFile)
.map(readFile(dirname))
module.exports = loadGraphQLFiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment