mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-03-22 17:00:27 +00:00
19 lines
No EOL
639 B
JavaScript
19 lines
No EOL
639 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;
|
|
}, {} );
|
|
}
|
|
}; |