mirror of
https://github.com/harish2704/npm-offline-registry.git
synced 2026-09-10 06:21:09 +00:00
Merge branch 'master' of github.com:harish2704/npm-offline-registry
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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( ';' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user