From 46c2be16def05347cd1199ad603f0f290dd73602 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 18 May 2018 13:41:25 -0400 Subject: [PATCH] don't unnecessary reload solc --- lib/modules/solidity/index.js | 13 +++++++------ lib/modules/solidity/solcW.js | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/modules/solidity/index.js b/lib/modules/solidity/index.js index 46012b2b..b28fb039 100644 --- a/lib/modules/solidity/index.js +++ b/lib/modules/solidity/index.js @@ -7,6 +7,8 @@ class Solidity { this.logger = embark.logger; this.events = embark.events; this.contractDirectories = options.contractDirectories; + this.solcAlreadyLoaded = false; + this.solcW = null; embark.registerCompiler(".sol", this.compile_solidity.bind(this)); } @@ -17,7 +19,6 @@ class Solidity { } let self = this; let input = {}; - let solcW; async.waterfall([ function prepareInput(callback) { async.each(contractFiles, @@ -44,14 +45,14 @@ class Solidity { ); }, function loadCompiler(callback) { - // TODO: there ino need to load this twice - solcW = new SolcW({logger: self.logger, events: self.events}); - if (solcW.isCompilerLoaded()) { + if (self.solcAlreadyLoaded) { return callback(); } + self.solcW = new SolcW({logger: self.logger, events: self.events}); self.logger.info(__("loading solc compiler") + ".."); - solcW.load_compiler(function (err) { + self.solcW.load_compiler(function (err) { + self.solcAlreadyLoaded = true; callback(err); }); }, @@ -73,7 +74,7 @@ class Solidity { } }; - solcW.compile(jsonObj, function (output) { + self.solcW.compile(jsonObj, function (output) { if (output.errors) { for (let i=0; i { + self.solcProcess.unsubscribeTo('result', 'compilation'); done(JSON.parse(msg.output)); });