mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-07 08:31:02 +00:00
19 lines
No EOL
632 B
JavaScript
19 lines
No EOL
632 B
JavaScript
var fs = require( 'fs' ),
|
|
path = require( 'path' ),
|
|
Adapter = require( './messaging/collector-adapter.js'),
|
|
collectorPath = './collectors';
|
|
|
|
module.exports = {
|
|
load: function ( searchChannel, statsChannel ) {
|
|
return fs.readdirSync( collectorPath ).reduce( function ( accum, collector ) {
|
|
try {
|
|
var instance = new ( require( path.join( path.resolve( collectorPath ), collector ) ) )(collector.replace(/.js\b/, ""));
|
|
accum[ collector ] = new Adapter( instance, searchChannel, statsChannel );
|
|
}
|
|
catch ( ex ) {
|
|
console.log( "Unable to load '" + collector + "' - " + ex );
|
|
}
|
|
return accum;
|
|
}, {});
|
|
}
|
|
}; |