requirize
v0.2.0
Published
Require a directory and construct a hash representing the required files. Keys are filenames minus the file extension and the respective values are the exported object.
Downloads
4,471
Readme
Requirize
This is a small utility to require a directory of files and construct a hash representing the required files. eg.
Given a directory stucture such as:
dir
- cat.js
- dog.js
- fish.js
- long-filename.js
- index.js
- zebra.js
And we use requirize in index.js like:
module.exports = require('requirize')(__dirname);
When requiring this directory we will be return an object like. Filenames are camelized.
{
"cat": <<module contents>>,
"dog": <<module contents>>,
"fish": <<module contents>>,
"longFilename": <<module contents>>,
"zebra": <<module contents>>
}