feat: add new event before build

This commit is contained in:
Anthony Laibe 2018-11-22 10:45:49 +00:00 committed by Iuri Matias
parent 17cec1b787
commit db35d7f573
4 changed files with 13 additions and 1 deletions

View File

@ -212,7 +212,7 @@ class Engine {
this.registerModule('compiler', {plugins: this.plugins, disableOptimizations: options.disableOptimizations}); this.registerModule('compiler', {plugins: this.plugins, disableOptimizations: options.disableOptimizations});
this.registerModule('solidity', {ipc: this.ipc, useDashboard: this.useDashboard}); this.registerModule('solidity', {ipc: this.ipc, useDashboard: this.useDashboard});
this.registerModule('vyper'); this.registerModule('vyper');
this.registerModule('contracts_manager', {compileOnceOnly: options.compileOnceOnly}); this.registerModule('contracts_manager', {plugins: this.plugins, compileOnceOnly: options.compileOnceOnly});
} }
deploymentService(options) { deploymentService(options) {

View File

@ -57,6 +57,10 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig) {
var plugin; var plugin;
try { try {
plugin = require(pluginPath); plugin = require(pluginPath);
if (plugin.default) {
plugin = plugin.default;
}
} catch(_e) { } catch(_e) {
pluginPath = fs.embarkPath('modules/' + pluginName); pluginPath = fs.embarkPath('modules/' + pluginName);
plugin = require(pluginPath); plugin = require(pluginPath);

View File

@ -13,6 +13,7 @@ class ContractsManager {
const self = this; const self = this;
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.plugins = options.plugins;
this.contracts = {}; this.contracts = {};
this.contractDependencies = {}; this.contractDependencies = {};
@ -226,6 +227,11 @@ class ContractsManager {
if(resetContracts) self.contracts = {}; if(resetContracts) self.contracts = {};
async.waterfall([ async.waterfall([
function beforeBuild(callback) {
self.plugins.emitAndRunActionsForEvent("build:beforeAll", () => {
callback();
});
},
function loadContractFiles(callback) { function loadContractFiles(callback) {
self.events.request("config:contractsFiles", (contractsFiles) => { self.events.request("config:contractsFiles", (contractsFiles) => {
self.contractsFiles = contractsFiles; self.contractsFiles = contractsFiles;

View File

@ -114,6 +114,7 @@ describe('embark.Contracts', function() {
}; };
let contractsManager = new ContractsManager(embarkObj, { let contractsManager = new ContractsManager(embarkObj, {
plugins: plugins,
contractDirectories: ['app/contracts'] contractDirectories: ['app/contracts']
}); });
@ -239,6 +240,7 @@ describe('embark.Contracts', function() {
} }
let contractsManager = new ContractsManager(embarkObj, { let contractsManager = new ContractsManager(embarkObj, {
plugins: plugins,
contractDirectories: ['app/contracts'] contractDirectories: ['app/contracts']
}); });