Skip to content

Commit 414c875

Browse files
committed
add versions command
1 parent 232f6fc commit 414c875

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

lib/core/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var File = require('./file.js');
33
var Plugins = require('./plugins.js');
44
var utils = require('../utils/utils.js');
55
var Npm = require('../pipeline/npm.js');
6+
let currentWeb3Version = require('../../package.json').dependencies.web3.replace("^","");
67

78
// TODO: add wrapper for fs so it can also work in the browser
89
// can work with both read and save
@@ -250,7 +251,7 @@ Config.prototype.loadFiles = function(files) {
250251

251252
if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) {
252253
let web3Version = self.contractsConfig.versions["web3.js"];
253-
if (web3Version) {
254+
if (web3Version && web3Version != currentWeb3Version) {
254255
//if (false) {
255256
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
256257
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {

lib/dashboard/console.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ class Console {
55
constructor(options) {
66
this.plugins = options.plugins;
77
this.version = options.version;
8+
this.contractsConfig = options.contractsConfig;
89
}
910

1011
runCode(code) {
11-
try {
12-
RunCode.doEval(code); // jshint ignore:line
13-
} catch(e) {
14-
console.log(code);
15-
console.debug(e);
16-
}
12+
RunCode.doEval(code); // jshint ignore:line
1713
}
1814

1915
processEmbarkCmd (cmd) {
@@ -22,6 +18,7 @@ class Console {
2218
'Welcome to Embark ' + this.version,
2319
'',
2420
'possible commands are:',
21+
'versions - display versions in use for libraries and tools like web3 and solc',
2522
// TODO: only if the blockchain is actually active!
2623
// will need to pass te current embark state here
2724
'web3 - instantiated web3.js object configured to the current environment',
@@ -30,6 +27,20 @@ class Console {
3027
'The web3 object and the interfaces for the deployed contracts and their methods are also available'
3128
];
3229
return helpText.join('\n');
30+
} else if (cmd === 'versions') {
31+
//let currentSolcVersion = require('../../package.json').dependencies.solc;
32+
let solcVersionInConfig = this.contractsConfig.versions.solc;
33+
34+
//let web3Version = require('../../package.json').dependencies["web3.js"].replace("^","");
35+
let web3VersionInConfig = this.contractsConfig.versions["web3.js"];
36+
37+
let text = [
38+
'versions in use:',
39+
'solc: ' + solcVersionInConfig,
40+
'web3.js: ' + web3VersionInConfig
41+
]
42+
43+
return text.join('\n');
3344
} else if (cmd === 'quit') {
3445
utils.exit();
3546
}

lib/dashboard/dashboard.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Dashboard {
99
this.plugins = options.plugins;
1010
this.version = options.version;
1111
this.env = options.env;
12+
this.contractsConfig = options.contractsConfig;
1213
}
1314

1415
start(done) {
@@ -17,7 +18,7 @@ class Dashboard {
1718

1819
async.waterfall([
1920
function startConsole(callback) {
20-
console = new Console({plugins: self.plugins, version: self.version});
21+
console = new Console({plugins: self.plugins, version: self.version, contractsConfig: self.contractsConfig});
2122
callback();
2223
},
2324
function startMonitor(callback) {

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class Embark {
7676
logger: engine.logger,
7777
plugins: engine.plugins,
7878
version: self.version,
79-
env: engine.env
79+
env: engine.env,
80+
contractsConfig: engine.config.contractsConfig
8081
});
8182
dashboard.start(function () {
8283
engine.events.on('code-generator-ready', function () {

0 commit comments

Comments
 (0)