add config to the plugin api (temporary)

This commit is contained in:
Iuri Matias 2017-03-05 20:25:09 -05:00
parent 8325943bd7
commit 007be84f23
3 changed files with 4 additions and 2 deletions

View File

@ -36,7 +36,7 @@ Config.prototype.loadConfigFiles = function(options) {
this.embarkConfig = fs.readJSONSync(options.embarkConfig); this.embarkConfig = fs.readJSONSync(options.embarkConfig);
this.embarkConfig.plugins = this.embarkConfig.plugins || {}; this.embarkConfig.plugins = this.embarkConfig.plugins || {};
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events}); this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events, config: this});
this.plugins.loadPlugins(); this.plugins.loadPlugins();
this.loadEmbarkConfigFile(); this.loadEmbarkConfigFile();

View File

@ -20,6 +20,7 @@ var Plugin = function(options) {
this.pluginTypes = []; this.pluginTypes = [];
this.logger = options.logger; this.logger = options.logger;
this.events = options.events; this.events = options.events;
this.config = options.config;
}; };
Plugin.prototype.loadPlugin = function() { Plugin.prototype.loadPlugin = function() {

View File

@ -8,6 +8,7 @@ var Plugins = function(options) {
// TODO: need backup 'NullLogger' // TODO: need backup 'NullLogger'
this.logger = options.logger; this.logger = options.logger;
this.events = options.events; this.events = options.events;
this.config = options.config;
}; };
Plugins.prototype.loadPlugins = function() { Plugins.prototype.loadPlugins = function() {
@ -30,7 +31,7 @@ Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
var pluginPath = utils.joinPath(process.env.PWD, 'node_modules', pluginName); var pluginPath = utils.joinPath(process.env.PWD, 'node_modules', pluginName);
var plugin = require(pluginPath); var plugin = require(pluginPath);
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs, events: this.events}); var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs, events: this.events, config: this.config});
pluginWrapper.loadPlugin(); pluginWrapper.loadPlugin();
this.plugins.push(pluginWrapper); this.plugins.push(pluginWrapper);
}; };