diff --git a/lib/compiler.js b/lib/compiler.js index cf29c982..9d2c5a94 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,3 +1,4 @@ +/*jshint esversion: 6, loopfunc: true */ var shelljs = require('shelljs'); var shelljs_global = require('shelljs/global'); var fs = require('fs'); @@ -15,13 +16,15 @@ Compiler.prototype.compile_contracts = function(contractFiles) { ".sol": this.compile_solidity }; - var compilerPlugins = this.plugins.getPluginsFor('compilers'); - if (compilerPlugins.length > 0) { - compilerPlugins.forEach(function(plugin) { - plugin.compilers.forEach(function(compilerObject) { - available_compilers[compilerObject.extension] = compilerObject.cb; + if (this.plugins) { + var compilerPlugins = this.plugins.getPluginsFor('compilers'); + if (compilerPlugins.length > 0) { + compilerPlugins.forEach(function(plugin) { + plugin.compilers.forEach(function(compilerObject) { + available_compilers[compilerObject.extension] = compilerObject.cb; + }); }); - }); + } } var compiledObject = {}; diff --git a/lib/config.js b/lib/config.js index 7e3e2b68..4fda03a2 100644 --- a/lib/config.js +++ b/lib/config.js @@ -16,11 +16,13 @@ var Config = function(options) { this.contractsFiles = []; this.configDir = options.configDir || 'config/'; this.chainsFile = options.chainsFile || './chains.json'; + this.plugins = options.plugins; this.logger = options.logger; }; Config.prototype.loadConfigFiles = function(options) { this.embarkConfig = JSON.parse(fs.readFileSync(options.embarkConfig)); + this.embarkConfig.plugins = this.embarkConfig.plugins || {}; this.loadPipelineConfigFile(); this.loadBlockchainConfigFile(); diff --git a/test/compiler.js b/test/compiler.js index adcb6e85..d39b9993 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -8,7 +8,7 @@ var readFile = function(file) { }; describe('embark.Compiler', function() { - var compiler = new Compiler(); + var compiler = new Compiler({}); describe('#compile_solidity', function() { var compiledContracts = compiler.compile_solidity([ diff --git a/test/config.js b/test/config.js index 3f3ef920..78aca2de 100644 --- a/test/config.js +++ b/test/config.js @@ -1,5 +1,6 @@ /*globals describe, it*/ var Config = require('../lib/config.js'); +var Plugins = require('../lib/plugins.js'); var assert = require('assert'); var fs = require('fs'); @@ -8,6 +9,7 @@ describe('embark.Config', function() { env: 'myenv', configDir: './test/test1/config/' }); + config.plugins = new Plugins({plugins: {}}); describe('#loadBlockchainConfigFile', function() { it('should load blockchain config correctly', function() { diff --git a/test/console.js b/test/console.js index 91a76750..c523b271 100644 --- a/test/console.js +++ b/test/console.js @@ -1,9 +1,11 @@ /*globals describe, it*/ var Console = require('../lib/console.js'); +var Plugins = require('../lib/plugins.js'); var assert = require('assert'); describe('embark.Console', function() { - var console = new Console(); + var plugins = new Plugins({plugins: {}}); + var console = new Console({plugins: plugins}); describe('#executeCmd', function() {