Merge branch 'master' of github.com:harish2704/npm-offline-registry

This commit is contained in:
2016-03-29 10:47:17 +05:30
4 changed files with 13 additions and 12 deletions
+6 -4
View File
@@ -12,10 +12,12 @@ Supper simple NPM registry server for offline NPM install
*OR* *OR*
`node node_modules/.bin/npm-offline-registry` `node node_modules/.bin/npm-offline-registry`
* Now the server will run on [http://localhost:8080](http://localhost:8080) * Now the server will run on [http://localhost:8234](http://localhost:8234)
* use `http://localhost:8080/` as registry while doing npm install * use `http://localhost:8234/` as registry while doing npm install
- Either use `npm install --registry http://localhost:8080/ [package-name]...` - Either use `npm install --registry http://localhost:8234/ [package-name]...`
- Or permanently set config variable `npm config set registry http://localhost:8080/` - Or permanently set config variable `npm config set registry http://localhost:8234/`
**NOTE:** *default port can be changed by setting `PORT` environment variable *
# How it is working? # How it is working?
+3 -6
View File
@@ -6,12 +6,13 @@
var app = require('../app'); var app = require('../app');
var http = require('http'); var http = require('http');
var config = require( __dirname + '/../config' );
/** /**
* Get port from environment and store in Express. * Get port from environment and store in Express.
*/ */
var port = normalizePort(process.env.PORT || '8080'); var port = normalizePort( config.PORT );
app.set('port', port); app.set('port', port);
/** /**
@@ -81,9 +82,5 @@ function onError(error) {
*/ */
function onListening() { function onListening() {
var addr = server.address(); console.log('Listening on http://' + config.LOCAL_REGISTRY );
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
console.log('Listening on ' + bind);
} }
+3 -1
View File
@@ -2,7 +2,7 @@
var defaultConfig = { var defaultConfig = {
NPM_PATH : process.env.HOME + '/.npm', NPM_PATH : process.env.HOME + '/.npm',
REGISTRY_NAME : 'registry.npmjs.org', REGISTRY_NAME : 'registry.npmjs.org',
LOCAL_REGISTRY : 'localhost:8080', PORT: 8234
}; };
var config = {}; var config = {};
@@ -11,5 +11,7 @@ Object.keys( defaultConfig ).forEach( function(v){
config[v] = process.env[v] || defaultConfig[v]; config[v] = process.env[v] || defaultConfig[v];
}); });
config.LOCAL_REGISTRY = 'localhost:' + config.PORT;
module.exports = config; module.exports = config;
+1 -1
View File
@@ -34,7 +34,7 @@ exports.patchData = function ( data ){
}; };
var fetchAndCacheMetadataCmd =[ var fetchAndCacheMetadataCmd =[
'mkdir $packageCacheDir', 'mkdir -p $packageCacheDir',
'wget -nv "http://$REGISTRY_NAME/$packageName" -O $cacheFile || { wgetExitStatus=$? && rm $cacheFile; exit $wgetExitStatus ; }' 'wget -nv "http://$REGISTRY_NAME/$packageName" -O $cacheFile || { wgetExitStatus=$? && rm $cacheFile; exit $wgetExitStatus ; }'
].join( ';' ); ].join( ';' );