From 1cdcaee7d922a9678344d2537e29ac72dda5bcc3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 29 Jan 2017 01:28:01 -0500 Subject: [PATCH] fix specs --- lib/compiler.js | 15 +++++++++------ lib/config.js | 2 ++ test/compiler.js | 2 +- test/config.js | 2 ++ test/console.js | 4 +++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index cf29c9824..9d2c5a945 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 7e3e2b682..4fda03a22 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 adcb6e85f..d39b99934 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 3f3ef9207..78aca2de8 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 91a767504..c523b2711 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() {