File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 11let utils = require ( '../utils/utils.js' ) ;
22let solcProcess ;
33let compilerLoaded = false ;
4- var npm = require ( '../pipeline/npm.js' ) ;
4+ var Npm = require ( '../pipeline/npm.js' ) ;
55let path = require ( 'path' ) ;
66let currentSolcVersion = require ( '../../package.json' ) . dependencies . solc ;
77
88class 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 } ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ var fs = require('./fs.js');
22var File = require ( './file.js' ) ;
33var Plugins = require ( './plugins.js' ) ;
44var 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 } ) ;
Original file line number Diff line number Diff line change @@ -6,8 +6,14 @@ let http = require('follow-redirects').http;
66let https = require ( 'follow-redirects' ) . https ;
77var 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 ;
You can’t perform that action at this time.
0 commit comments