From 1df6d6d94acd70420ae6d7e3cfb1009c2be6b856 Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Tue, 10 May 2016 21:34:24 +0100 Subject: [PATCH 1/2] Allow LOCAL_REGISTRY to be set from env --- config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index 141223a..0e3405c 100644 --- a/config.js +++ b/config.js @@ -13,7 +13,10 @@ Object.keys( defaultConfig ).forEach( function(v){ }); -config.LOCAL_REGISTRY = 'localhost:' + config.PORT; +if( !config.LOCAL_REGISTRY ){ + config.LOCAL_REGISTRY = 'localhost:' + config.PORT; +} + if( config.ENABLE_NPM_FAILOVER == 'false' ){ config.ENABLE_NPM_FAILOVER = false; } From e4d13bebe0a324f94cad15c9bf633f3c45ac1128 Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Tue, 10 May 2016 21:50:11 +0100 Subject: [PATCH 2/2] Account for https registry URLs --- bin/www | 2 +- config.js | 2 +- utils.js | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/www b/bin/www index 0961fde..2e396b5 100755 --- a/bin/www +++ b/bin/www @@ -82,5 +82,5 @@ function onError(error) { */ function onListening() { - console.log('Listening on http://' + config.LOCAL_REGISTRY ); + console.log('Listening on http://0.0.0.0:' + port ); } diff --git a/config.js b/config.js index 0e3405c..496ca3d 100644 --- a/config.js +++ b/config.js @@ -14,7 +14,7 @@ Object.keys( defaultConfig ).forEach( function(v){ if( !config.LOCAL_REGISTRY ){ - config.LOCAL_REGISTRY = 'localhost:' + config.PORT; + config.LOCAL_REGISTRY = 'http://localhost:' + config.PORT; } if( config.ENABLE_NPM_FAILOVER == 'false' ){ diff --git a/utils.js b/utils.js index 634e053..c4d7491 100644 --- a/utils.js +++ b/utils.js @@ -29,7 +29,11 @@ exports.readFile = readFile; exports.patchData = function ( data ){ Object.keys(data.versions).forEach( function( v ){ var val = data.versions[v]; - val.dist.tarball = val.dist.tarball.replace( REGISTRY_NAME, LOCAL_REGISTRY ); + var protocal = 'http://'; + if( val.dist.tarball.indexOf( 'https:' ) !== false ){ + protocal = 'https://'; + } + val.dist.tarball = val.dist.tarball.replace( protocal + REGISTRY_NAME, LOCAL_REGISTRY ); }); };