ats-loader
v0.0.3
Published
Load modules from a folder by pattern
Downloads
1
Readme
ats-loader
Module for NodeJS. Load modules from a folder by pattern
Install:
npm install ats-loader
File system:
- controllers
- mainController.js
- someModule.js
- pageController.js
- api
- userController.js
- anyController.js
- bla-bla-bla.js
- index.js
Code of index.js:
var moduleLoader = require("ats-loader");
var ctrl = moduleLoader.load(__dirname + "/controllers", /Controller\.js/);
console.log(ctrl);
Result:
{
main: Module,
page: Module,
api: {
user: Module,
any: Module
}
}
Files "controllers/someModule.js" and "controllers/api/bla-bla-bla.js" were ignored because they do not fall into the pattern