Created
April 13, 2019 18:21
-
-
Save cgrinker/2e876d8248be4ad8f36180801e62eb52 to your computer and use it in GitHub Desktop.
Export all files in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
module.exports = fs.readdirSync(__dirname ) | |
.filter((e)=>{return e !== 'index.js'}) | |
.map((e)=> { | |
return [e.split('.')[0], require(`./${e}`)] | |
}) | |
.reduce((acc, val)=> { | |
acc[val[0]] = val[1]; | |
return acc; | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment