diff --git a/lib/modules/solidity/solcW.js b/lib/modules/solidity/solcW.js index a7c1d6eb..2cadd869 100644 --- a/lib/modules/solidity/solcW.js +++ b/lib/modules/solidity/solcW.js @@ -1,7 +1,6 @@ let utils = require('../../utils/utils.js'); let solcProcess; let compilerLoaded = false; -var Npm = require('../../pipeline/npm.js'); let currentSolcVersion = require('../../../package.json').dependencies.solc; class SolcW { @@ -27,17 +26,17 @@ class SolcW { this.events.request("version:get:solc", function(solcVersion) { self.logger.info("detected version is " + solcVersion); - if (self.solcVersion === currentSolcVersion) { + if (solcVersion === currentSolcVersion) { solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'}); } else { - let npm = new Npm({logger: self.logger}); - npm.getPackageVersion('solc', solcVersion, false, false, function(err, location) { + self.events.request("version:getPackage:solc", solcVersion, function(err, location) { if (err) { return done(err); } let requirePath = utils.joinPath(process.env.PWD, location); solcProcess.send({action: 'loadCompiler', solcLocation: requirePath}); }); + } }); } diff --git a/lib/versions/library_manager.js b/lib/versions/library_manager.js index ad6f6b23..d9020bb3 100644 --- a/lib/versions/library_manager.js +++ b/lib/versions/library_manager.js @@ -1,3 +1,4 @@ +var Npm = require('../pipeline/npm.js'); class LibraryManager { @@ -11,7 +12,8 @@ class LibraryManager { this.determineVersions(); this.registerCommands(); - this.listenToCommands(); + this.listenToCommandsToGetVersions(); + this.listenToCommandsToGetLibrary(); } determineVersions() { @@ -40,7 +42,7 @@ class LibraryManager { }); } - listenToCommands() { + listenToCommandsToGetVersions() { const self = this; for (let libName in this.versions) { let lib = self.versions[libName]; @@ -50,6 +52,14 @@ class LibraryManager { } } + listenToCommandsToGetLibrary() { + let libName = "solc"; + let npm = new Npm({logger: this.embark.logger}); + this.embark.events.setCommandHandler('version:getPackage:' + libName, (version, cb) => { + npm.getPackageVersion('solc', version, false, false, cb); + }); + } + } module.exports = LibraryManager; diff --git a/test/compiler.js b/test/compiler.js index fd7cedb9..36efed82 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -14,7 +14,6 @@ var solcVersion = "0.4.17"; var TestEvents = { request: (cmd, cb) => { - console.log("hello!"); cb(solcVersion) } };