Browse Source

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

pull/1/head
Harish.K 10 years ago
parent
commit
8327d070dc
  1. 10
      README.md
  2. 9
      bin/www
  3. 4
      config.js
  4. 2
      utils.js

10
README.md

@ -12,10 +12,12 @@ Supper simple NPM registry server for offline NPM install
*OR*
`node node_modules/.bin/npm-offline-registry`
* Now the server will run on [http://localhost:8080](http://localhost:8080)
* use `http://localhost:8080/` as registry while doing npm install
- Either use `npm install --registry http://localhost:8080/ [package-name]...`
- Or permanently set config variable `npm config set registry http://localhost:8080/`
* Now the server will run on [http://localhost:8234](http://localhost:8234)
* use `http://localhost:8234/` as registry while doing npm install
- Either use `npm install --registry http://localhost:8234/ [package-name]...`
- 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?

9
bin/www

@ -6,12 +6,13 @@
var app = require('../app');
var http = require('http');
var config = require( __dirname + '/../config' );
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '8080');
var port = normalizePort( config.PORT );
app.set('port', port);
/**
@ -81,9 +82,5 @@ function onError(error) {
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
console.log('Listening on ' + bind);
console.log('Listening on http://' + config.LOCAL_REGISTRY );
}

4
config.js

@ -2,7 +2,7 @@
var defaultConfig = {
NPM_PATH : process.env.HOME + '/.npm',
REGISTRY_NAME : 'registry.npmjs.org',
LOCAL_REGISTRY : 'localhost:8080',
PORT: 8234
};
var config = {};
@ -11,5 +11,7 @@ Object.keys( defaultConfig ).forEach( function(v){
config[v] = process.env[v] || defaultConfig[v];
});
config.LOCAL_REGISTRY = 'localhost:' + config.PORT;
module.exports = config;

2
utils.js

@ -34,7 +34,7 @@ exports.patchData = function ( data ){
};
var fetchAndCacheMetadataCmd =[
'mkdir $packageCacheDir',
'mkdir -p $packageCacheDir',
'wget -nv "http://$REGISTRY_NAME/$packageName" -O $cacheFile || { wgetExitStatus=$? && rm $cacheFile; exit $wgetExitStatus ; }'
].join( ';' );

Loading…
Cancel
Save