Skip to content

Instantly share code, notes, and snippets.

@jimkang
Created September 18, 2018 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimkang/94dc939a58ee4c750cf29fa2678d1e6b to your computer and use it in GitHub Desktop.
Save jimkang/94dc939a58ee4c750cf29fa2678d1e6b to your computer and use it in GitHub Desktop.
Requiring all files in a directory
/* global __dirname */
var fs = require('fs');
var files = fs.readdirSync(__dirname).filter(isAConfigFile);
var configs = files.map(file => require(__dirname + '/' + file));
function isAConfigFile(filename) {
return filename.endsWith('-config.js');
}
module.exports = configs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment