add events to plugin api
This commit is contained in:
parent
3db27c14cb
commit
269552aee0
|
@ -16,6 +16,7 @@ var Config = function(options) {
|
|||
this.chainsFile = options.chainsFile || './chains.json';
|
||||
this.plugins = options.plugins;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
};
|
||||
|
||||
Config.prototype.loadConfigFiles = function(options) {
|
||||
|
@ -34,7 +35,7 @@ Config.prototype.loadConfigFiles = function(options) {
|
|||
this.embarkConfig = fs.readJSONSync(options.embarkConfig);
|
||||
this.embarkConfig.plugins = this.embarkConfig.plugins || {};
|
||||
|
||||
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs});
|
||||
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events});
|
||||
this.plugins.loadPlugins();
|
||||
|
||||
this.loadEmbarkConfigFile();
|
||||
|
|
|
@ -21,7 +21,7 @@ Engine.prototype.init = function(_options) {
|
|||
var options = _options || {};
|
||||
this.events = new Events();
|
||||
this.logger = options.logger || new Logger({logLevel: 'debug'});
|
||||
this.config = new Config({env: this.env, logger: this.logger});
|
||||
this.config = new Config({env: this.env, logger: this.logger, events: this.events});
|
||||
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
||||
this.plugins = this.config.plugins;
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@ var Plugin = function(options) {
|
|||
this.compilers = [];
|
||||
this.pluginTypes = [];
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
};
|
||||
|
||||
Plugin.prototype.loadPlugin = function() {
|
||||
|
|
|
@ -7,6 +7,7 @@ var Plugins = function(options) {
|
|||
this.plugins = [];
|
||||
// TODO: need backup 'NullLogger'
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
};
|
||||
|
||||
Plugins.prototype.loadPlugins = function() {
|
||||
|
@ -29,7 +30,7 @@ Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
|
|||
var pluginPath = utils.joinPath(process.env.PWD, 'node_modules', pluginName);
|
||||
var plugin = require(pluginPath);
|
||||
|
||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs});
|
||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs, events: this.events});
|
||||
pluginWrapper.loadPlugin();
|
||||
this.plugins.push(pluginWrapper);
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ var Embark = {
|
|||
this.events = new Events();
|
||||
this.logger = new Logger({logLevel: 'debug'});
|
||||
|
||||
this.config = new Config({env: env, logger: this.logger});
|
||||
this.config = new Config({env: env, logger: this.logger, events: this.events});
|
||||
this.config.loadConfigFiles(options);
|
||||
this.plugins = this.config.plugins;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue