From 269552aee0134b46834fc1d99de2200470a48b75 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 4 Mar 2017 12:42:24 -0500 Subject: [PATCH] add events to plugin api --- lib/core/config.js | 3 ++- lib/core/engine.js | 2 +- lib/core/plugin.js | 1 + lib/core/plugins.js | 3 ++- lib/index.js | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 81465c63..294b3419 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -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(); diff --git a/lib/core/engine.js b/lib/core/engine.js index 527b2c8e..2da3e6c1 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -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; }; diff --git a/lib/core/plugin.js b/lib/core/plugin.js index e44f6f1f..4f72b8c3 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -19,6 +19,7 @@ var Plugin = function(options) { this.compilers = []; this.pluginTypes = []; this.logger = options.logger; + this.events = options.events; }; Plugin.prototype.loadPlugin = function() { diff --git a/lib/core/plugins.js b/lib/core/plugins.js index 1f2081b1..7b852848 100644 --- a/lib/core/plugins.js +++ b/lib/core/plugins.js @@ -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); }; diff --git a/lib/index.js b/lib/index.js index 2da436a6..7964c56b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; },