Add getModulePaths to module_util, call it from events.registerModules

This commit is contained in:
Josh M. McKee 2017-06-11 19:44:34 -07:00
parent 06e84eee94
commit b383950314
2 changed files with 31 additions and 21 deletions

View File

@ -23,10 +23,12 @@ var self = module.exports = {
eventEmitter.removeListener(eventName, listener);
},
registerModules: function() {
var mods = fs.readdirSync(Config.config.paths.mods);
const moduleUtil = require('./module_util.js');
moduleUtil.getModulePaths().forEach(function(modulePath) {
var mods = fs.readdirSync(modulePath);
mods.forEach(function(item) {
var modPath = Config.config.paths.mods+item;
var modPath = modulePath+item;
if (item.substr(item.length-3) != '.js') {
modPath += path.sep+item+'.js';
}
@ -43,5 +45,6 @@ var self = module.exports = {
logger.log.debug(modPath+" - file not found");
}
});
});
}
}

View File

@ -15,6 +15,7 @@ const async = require('async');
exports.loadModuleEx = loadModuleEx;
exports.loadModule = loadModule;
exports.loadModulesForCategory = loadModulesForCategory;
exports.getModulePaths = getModulePaths;
function loadModuleEx(options, cb) {
assert(_.isObject(options));
@ -97,3 +98,9 @@ function loadModulesForCategory(category, iterator, complete) {
});
});
}
function getModulePaths() {
return [
Config.paths.mods
];
}