-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadeventhandlers.js
37 lines (31 loc) · 1.06 KB
/
loadeventhandlers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var evtcmdbus = require('./evtcmdbus'),
_ = require('underscore'),
//user = require("./user"),
logger = require("winston"),
fs = require('fs'),
async = require('async')
;
var evtHandlerDir = "./eventhandlers";
fs.readdir(evtHandlerDir,function(err,files){
if (err) return;
var jsFiles = _.filter(files,function(filename){
var patt = new RegExp(".*\.js$");
return patt.test(filename);
});
_.each(jsFiles,function(element,index,list){
var fullPath = evtHandlerDir + "/" + element;
//logger.debug("processing handlers in: " + fullPath);
var evtModule = require(fullPath);
var handlers = _.functions(evtModule);
_.each(handlers,function(element,index,list){
//logger.debug("handler: " + element + " : function: " + evtModule[element] );
evtcmdbus.addEventSubscriber(element,evtModule[element]);
});
});
});
//var funcs = _.functions(user);
//_.each(funcs,function(element,index,list){
// logger.debug(element);
// logger.debug(user[element]);
//
//});