|
|
@ -5,10 +5,10 @@ var fs = require('fs'),
|
|
|
|
async = require('async'),
|
|
|
|
async = require('async'),
|
|
|
|
winston = require('winston'),
|
|
|
|
winston = require('winston'),
|
|
|
|
nconf = require('nconf'),
|
|
|
|
nconf = require('nconf'),
|
|
|
|
eventEmitter = require('events').EventEmitter,
|
|
|
|
|
|
|
|
semver = require('semver'),
|
|
|
|
semver = require('semver'),
|
|
|
|
|
|
|
|
|
|
|
|
db = require('./database'),
|
|
|
|
db = require('./database'),
|
|
|
|
|
|
|
|
emitter = require('./emitter'),
|
|
|
|
meta = require('./meta'),
|
|
|
|
meta = require('./meta'),
|
|
|
|
utils = require('../public/src/utils'),
|
|
|
|
utils = require('../public/src/utils'),
|
|
|
|
pkg = require('../package.json');
|
|
|
|
pkg = require('../package.json');
|
|
|
@ -24,9 +24,6 @@ var fs = require('fs'),
|
|
|
|
|
|
|
|
|
|
|
|
Plugins.initialized = false;
|
|
|
|
Plugins.initialized = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Events
|
|
|
|
|
|
|
|
Plugins.readyEvent = new eventEmitter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Plugins.init = function() {
|
|
|
|
Plugins.init = function() {
|
|
|
|
if (Plugins.initialized) {
|
|
|
|
if (Plugins.initialized) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -47,14 +44,15 @@ var fs = require('fs'),
|
|
|
|
if (global.env === 'development') {
|
|
|
|
if (global.env === 'development') {
|
|
|
|
winston.info('[plugins] Plugins OK');
|
|
|
|
winston.info('[plugins] Plugins OK');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Plugins.initialized = true;
|
|
|
|
Plugins.initialized = true;
|
|
|
|
Plugins.readyEvent.emit('ready');
|
|
|
|
emitter.emit('plugins:loaded');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Plugins.ready = function(callback) {
|
|
|
|
Plugins.ready = function(callback) {
|
|
|
|
if (!Plugins.initialized) {
|
|
|
|
if (!Plugins.initialized) {
|
|
|
|
Plugins.readyEvent.once('ready', callback);
|
|
|
|
emitter.once('plugins:loaded', callback);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|