Skip to content

Commit 5a2cdb1

Browse files
committed
use existing version of lib if versions match
1 parent f45ce96 commit 5a2cdb1

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

lib/contracts/compiler.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ class Compiler {
6666
callback(err);
6767
}
6868
);
69-
//for (let i = 0; i < contractFiles.length; i++) {
70-
// // TODO: this depends on the config
71-
// let filename = contractFiles[i].filename.replace('app/contracts/', '');
72-
// input[filename] = contractFiles[i].content.toString();
73-
//}
74-
//callback();
7569
},
7670
function loadCompiler(callback) {
7771
// TODO: there ino need to load this twice

lib/contracts/solcP.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ let solc;
22

33
process.on('message', function (msg) {
44
if (msg.action === 'loadCompiler') {
5-
//solc = require('solc');
6-
//console.log("requiring compiler at " + msg.solcLocation);
75
solc = require(msg.solcLocation);
86
process.send({result: "loadedCompiler"});
97
}

lib/contracts/solcW.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ let solcProcess;
33
let compilerLoaded = false;
44
var npm = require('../pipeline/npm.js');
55
let path = require('path');
6+
let currentSolcVersion = require('../../package.json').dependencies.solc;
67

78
class SolcW {
89

9-
constructor(version) {
10-
this.solcVersion = version;
10+
constructor(solcVersion) {
11+
this.solcVersion = solcVersion;
1112
}
1213

1314
load_compiler(done) {
@@ -22,13 +23,16 @@ class SolcW {
2223
compilerLoaded = true;
2324
done();
2425
});
25-
npm.getPackageVersion('solc', '0.4.10', false, function(location) {
26-
console.log("new compiler installed at " + location);
27-
//let requirePath = path.join(process.env.PWD, location.substr(2));
28-
let requirePath = path.join(process.env.PWD, location);
29-
console.log(requirePath);
30-
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
31-
});
26+
27+
if (this.solcVersion === currentSolcVersion) {
28+
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
29+
} else {
30+
npm.getPackageVersion('solc', this.solcVersion, false, function(location) {
31+
let requirePath = path.join(process.env.PWD, location);
32+
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
33+
});
34+
}
35+
3236
}
3337

3438
isCompilerLoaded() {

0 commit comments

Comments
 (0)