Merge pull request #3 from 1stvamp/allow-local_register-overriding-from-env

Allow LOCAL_REGISTRY to be set from env
This commit is contained in:
2016-05-11 22:06:44 +05:30
3 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -82,5 +82,5 @@ function onError(error) {
*/ */
function onListening() { function onListening() {
console.log('Listening on http://' + config.LOCAL_REGISTRY ); console.log('Listening on http://0.0.0.0:' + port );
} }
+4 -1
View File
@@ -13,7 +13,10 @@ Object.keys( defaultConfig ).forEach( function(v){
}); });
config.LOCAL_REGISTRY = 'localhost:' + config.PORT; if( !config.LOCAL_REGISTRY ){
config.LOCAL_REGISTRY = 'http://localhost:' + config.PORT;
}
if( config.ENABLE_NPM_FAILOVER == 'false' ){ if( config.ENABLE_NPM_FAILOVER == 'false' ){
config.ENABLE_NPM_FAILOVER = false; config.ENABLE_NPM_FAILOVER = false;
} }
+5 -1
View File
@@ -29,7 +29,11 @@ exports.readFile = readFile;
exports.patchData = function ( data ){ exports.patchData = function ( data ){
Object.keys(data.versions).forEach( function( v ){ Object.keys(data.versions).forEach( function( v ){
var val = data.versions[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 );
}); });
}; };