diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config/reg-client.js | 29 | ||||
-rw-r--r-- | lib/npm.js | 30 | ||||
-rw-r--r-- | lib/utils/get-publish-config.js | 16 |
3 files changed, 41 insertions, 34 deletions
diff --git a/lib/config/reg-client.js b/lib/config/reg-client.js new file mode 100644 index 000000000..d4e241709 --- /dev/null +++ b/lib/config/reg-client.js @@ -0,0 +1,29 @@ +'use strict' + +module.exports = regClientConfig +function regClientConfig (npm, log, config) { + return { + proxy: { + http: config.get('proxy'), + https: config.get('https-proxy'), + localAddress: config.get('local-address') + }, + ssl: { + certificate: config.get('cert'), + key: config.get('key'), + ca: config.get('ca'), + strict: config.get('strict-ssl') + }, + retry: { + retries: config.get('fetch-retries'), + factor: config.get('fetch-retry-factor'), + minTimeout: config.get('fetch-retry-mintimeout'), + maxTimeout: config.get('fetch-retry-maxtimeout') + }, + userAgent: config.get('user-agent'), + log: log, + defaultTag: config.get('tag'), + maxSockets: config.get('maxsockets'), + scope: npm.projectScope + } +} diff --git a/lib/npm.js b/lib/npm.js index dbd8e9715..990d8c510 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -33,6 +33,7 @@ var rimraf = require('rimraf') var lazyProperty = require('lazy-property') var parseJSON = require('./utils/parse-json.js') + var clientConfig = require('./config/reg-client.js') var aliases = require('./config/cmd-list').aliases var cmdList = require('./config/cmd-list').cmdList var plumbing = require('./config/cmd-list').plumbing @@ -344,7 +345,7 @@ lazyProperty(npm, 'registry', function () { registryLoaded = true var RegClient = require('npm-registry-client') - var registry = new RegClient(adaptClientConfig(npm.config)) + var registry = new RegClient(clientConfig(npm, log, npm.config)) registry.version = npm.version registry.refer = registryRefer return registry @@ -467,31 +468,4 @@ return '' } } - - function adaptClientConfig (config) { - return { - proxy: { - http: config.get('proxy'), - https: config.get('https-proxy'), - localAddress: config.get('local-address') - }, - ssl: { - certificate: config.get('cert'), - key: config.get('key'), - ca: config.get('ca'), - strict: config.get('strict-ssl') - }, - retry: { - retries: config.get('fetch-retries'), - factor: config.get('fetch-retry-factor'), - minTimeout: config.get('fetch-retry-mintimeout'), - maxTimeout: config.get('fetch-retry-maxtimeout') - }, - userAgent: config.get('user-agent'), - log: log, - defaultTag: config.get('tag'), - maxSockets: config.get('maxsockets'), - scope: npm.projectScope - } - } })() diff --git a/lib/utils/get-publish-config.js b/lib/utils/get-publish-config.js index fa475434f..ac0ef0934 100644 --- a/lib/utils/get-publish-config.js +++ b/lib/utils/get-publish-config.js @@ -1,12 +1,16 @@ -var Conf = require('../config/core.js').Conf -var RegClient = require('npm-registry-client') -var log = require('npmlog') +'use strict' + +const clientConfig = require('../config/reg-client.js') +const Conf = require('../config/core.js').Conf +const log = require('npmlog') +const npm = require('../npm.js') +const RegClient = require('npm-registry-client') module.exports = getPublishConfig function getPublishConfig (publishConfig, defaultConfig, defaultClient) { - var config = defaultConfig - var client = defaultClient + let config = defaultConfig + let client = defaultClient log.verbose('getPublishConfig', publishConfig) if (publishConfig) { config = new Conf(defaultConfig) @@ -18,7 +22,7 @@ function getPublishConfig (publishConfig, defaultConfig, defaultClient) { s[k] = publishConfig[k] return s }, {})) - client = new RegClient(config) + client = new RegClient(clientConfig(npm, log, config)) } return { config: config, client: client } |