Skip to content

Commit 2ed4eee

Browse files
committed
display loading message when new libs are being installed
1 parent 5a2cdb1 commit 2ed4eee

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

lib/contracts/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Compiler {
6969
},
7070
function loadCompiler(callback) {
7171
// TODO: there ino need to load this twice
72-
solcW = new SolcW(self.solcVersion);
72+
solcW = new SolcW({logger: self.logger, solcVersion: self.solcVersion});
7373
if (solcW.isCompilerLoaded()) {
7474
return callback();
7575
}

lib/contracts/solcW.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
let utils = require('../utils/utils.js');
22
let solcProcess;
33
let compilerLoaded = false;
4-
var npm = require('../pipeline/npm.js');
4+
var Npm = require('../pipeline/npm.js');
55
let path = require('path');
66
let currentSolcVersion = require('../../package.json').dependencies.solc;
77

88
class SolcW {
99

10-
constructor(solcVersion) {
11-
this.solcVersion = solcVersion;
10+
constructor(options) {
11+
this.solcVersion = options.solcVersion;
12+
this.logger = options.logger;
1213
}
1314

1415
load_compiler(done) {
@@ -27,6 +28,7 @@ class SolcW {
2728
if (this.solcVersion === currentSolcVersion) {
2829
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
2930
} else {
31+
let npm = new Npm({logger: this.logger});
3032
npm.getPackageVersion('solc', this.solcVersion, false, function(location) {
3133
let requirePath = path.join(process.env.PWD, location);
3234
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});

lib/core/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var fs = require('./fs.js');
22
var File = require('./file.js');
33
var Plugins = require('./plugins.js');
44
var utils = require('../utils/utils.js');
5-
var npm = require('../pipeline/npm.js');
5+
var Npm = require('../pipeline/npm.js');
66

77
// TODO: add wrapper for fs so it can also work in the browser
88
// can work with both read and save
@@ -240,6 +240,7 @@ Config.prototype.loadFiles = function(files) {
240240
//if (false) {
241241
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
242242
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {
243+
let npm = new Npm({logger: self.logger});
243244
npm.getPackageVersion('web3', web3Version, 'dist/web3.js', function(web3Content) {
244245
callback(web3Content);
245246
});

lib/pipeline/npm.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ let http = require('follow-redirects').http;
66
let https = require('follow-redirects').https;
77
var tar = require('tar');
88

9-
module.exports = {
10-
getPackageVersion: function(packageName, version, returnContent, callback) {
9+
class Npm {
10+
11+
constructor(options) {
12+
this.logger = options.logger;
13+
}
14+
15+
getPackageVersion(packageName, version, returnContent, callback) {
16+
let self = this;
1117
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
1218

1319
utils.httpsGet(npmRegistry, function (res) {
@@ -45,7 +51,7 @@ module.exports = {
4551
}
4652
} else {
4753
fs.mkdirpSync(packageDirectory);
48-
//self.logger.info("downloading " + packageName + " " + version + "....");
54+
self.logger.info("downloading " + packageName + " " + version + "....");
4955

5056
download(tarball, packageDirectory + "/downloaded_package.tgz", function() {
5157
o_fs.createReadStream(packageDirectory + '/downloaded_package.tgz').pipe(
@@ -68,5 +74,6 @@ module.exports = {
6874
});
6975
});
7076
}
71-
};
77+
}
7278

79+
module.exports = Npm;

0 commit comments

Comments
 (0)