1.0.3 • Published 7 years ago
require-dirs v1.0.3
require directory
function(dir,options)
dir
{String} is the directory pathoptions
{Object}exclude
: {String} RegExp pattern, exclude module which name match reg rulescase
: {String} The object field style. the value range {camel, snake, kebab ,capitalized). (defaultcamel
)depth
: {Number} limit the sub-directory search depth (defaultNumber.MAX_VALUE
)
example
The directory structure
├── fish.js
├── folder_with_index
│ ├── index.js
│ └── other_file.js
├── other_file.js
└── other_folder
├── badger.js
└── badger_fish.js
result
{
fish: require("./fish"),
folderWithIndex: {
index:require("./folder_with_index/index"),
otherFile:require("./folder_with_index/other_file"),
},
otherFile: require("./other_file"),
otherFolder: {
badger: require("./other_folder/badger"),
badgerFish: require("./other_folder/badger_fish")
}
}