mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 14:34:40 +00:00
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.chainsFile = options.chainsFile || './chains.json';
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
this.events = options.events;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.loadConfigFiles = function(options) {
|
Config.prototype.loadConfigFiles = function(options) {
|
||||||
@ -34,7 +35,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});
|
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events});
|
||||||
this.plugins.loadPlugins();
|
this.plugins.loadPlugins();
|
||||||
|
|
||||||
this.loadEmbarkConfigFile();
|
this.loadEmbarkConfigFile();
|
||||||
|
@ -21,7 +21,7 @@ Engine.prototype.init = function(_options) {
|
|||||||
var options = _options || {};
|
var options = _options || {};
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.logger = options.logger || new Logger({logLevel: 'debug'});
|
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.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,7 @@ var Plugin = function(options) {
|
|||||||
this.compilers = [];
|
this.compilers = [];
|
||||||
this.pluginTypes = [];
|
this.pluginTypes = [];
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
this.events = options.events;
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.loadPlugin = function() {
|
Plugin.prototype.loadPlugin = function() {
|
||||||
|
@ -7,6 +7,7 @@ var Plugins = function(options) {
|
|||||||
this.plugins = [];
|
this.plugins = [];
|
||||||
// TODO: need backup 'NullLogger'
|
// TODO: need backup 'NullLogger'
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
this.events = options.events;
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugins.prototype.loadPlugins = function() {
|
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 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});
|
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs, events: this.events});
|
||||||
pluginWrapper.loadPlugin();
|
pluginWrapper.loadPlugin();
|
||||||
this.plugins.push(pluginWrapper);
|
this.plugins.push(pluginWrapper);
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ var Embark = {
|
|||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.logger = new Logger({logLevel: 'debug'});
|
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.config.loadConfigFiles(options);
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user