Created
April 9, 2019 18:13
-
-
Save trezy/7203313f55b7bbab0d63d64e4186a92c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Module imports | |
import fs from 'fs' | |
import path from 'path' | |
function exportDirectory (requirePath) { | |
let exports = {} | |
for (const filename of fs.readdirSync(requirePath)) { | |
if (!/^index\./.test(filename)) { | |
exports = { | |
...exports, | |
...require(path.resolve(requirePath, filename)), | |
} | |
} | |
} | |
return exports | |
} | |
export { exportDirectory } |
This file contains hidden or 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
// Module imports | |
import { exportDirectory } from './exportDirectory' | |
module.exports = exportDirectory(__dirname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment