Last active
November 27, 2018 18:39
-
-
Save lk321/2a504b86279aaf1808805440878df856 to your computer and use it in GitHub Desktop.
Import files with index
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
const path = require('path'); | |
require('fs').readdirSync(__dirname).forEach((file) => { | |
/* If its the current file ignore it */ | |
if (file === 'index.js') return; | |
const MODULE = require(path.join(__dirname, file)); | |
module.exports[path.basename(file, '.js')] = MODULE.default || MODULE; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment