diff options
Diffstat (limited to 'node_modules/npm-registry-client/lib/initialize.js')
-rw-r--r-- | node_modules/npm-registry-client/lib/initialize.js | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/node_modules/npm-registry-client/lib/initialize.js b/node_modules/npm-registry-client/lib/initialize.js index e7215bc78..4a2160fbb 100644 --- a/node_modules/npm-registry-client/lib/initialize.js +++ b/node_modules/npm-registry-client/lib/initialize.js @@ -1,8 +1,8 @@ -var crypto = require("crypto") -var HttpAgent = require("http").Agent -var HttpsAgent = require("https").Agent +var crypto = require('crypto') +var HttpAgent = require('http').Agent +var HttpsAgent = require('https').Agent -var pkg = require("../package.json") +var pkg = require('../package.json') var httpAgent var httpsAgent @@ -11,20 +11,20 @@ module.exports = initialize function initialize (uri, method, accept, headers) { if (!this.config.sessionToken) { - this.config.sessionToken = crypto.randomBytes(8).toString("hex") - this.log.verbose("request id", this.config.sessionToken) + this.config.sessionToken = crypto.randomBytes(8).toString('hex') + this.log.verbose('request id', this.config.sessionToken) } var opts = { - url : uri, - method : method, - headers : headers, - localAddress : this.config.proxy.localAddress, - strictSSL : this.config.ssl.strict, - cert : this.config.ssl.certificate, - key : this.config.ssl.key, - ca : this.config.ssl.ca, - agent : getAgent(uri.protocol, this.config) + url: uri, + method: method, + headers: headers, + localAddress: this.config.proxy.localAddress, + strictSSL: this.config.ssl.strict, + cert: this.config.ssl.certificate, + key: this.config.ssl.key, + ca: this.config.ssl.ca, + agent: getAgent(uri.protocol, this.config) } // allow explicit disabling of proxy in environment via CLI @@ -32,18 +32,16 @@ function initialize (uri, method, accept, headers) { // how false gets here is the CLI's problem (it's gross) if (this.config.proxy.http === false) { opts.proxy = null - } - else { + } else { // request will not pay attention to the NOPROXY environment variable if a // config value named proxy is passed in, even if it's set to null. var proxy - if (uri.protocol === "https:") { + if (uri.protocol === 'https:') { proxy = this.config.proxy.https - } - else { + } else { proxy = this.config.proxy.http } - if (typeof proxy === "string") opts.proxy = proxy + if (typeof proxy === 'string') opts.proxy = proxy } headers.version = this.version || pkg.version @@ -51,32 +49,31 @@ function initialize (uri, method, accept, headers) { if (this.refer) headers.referer = this.refer - headers["npm-session"] = this.config.sessionToken - headers["user-agent"] = this.config.userAgent + headers['npm-session'] = this.config.sessionToken + headers['user-agent'] = this.config.userAgent return opts } function getAgent (protocol, config) { - if (protocol === "https:") { + if (protocol === 'https:') { if (!httpsAgent) { httpsAgent = new HttpsAgent({ - keepAlive : true, - localAddress : config.proxy.localAddress, - rejectUnauthorized : config.ssl.strict, - ca : config.ssl.ca, - cert : config.ssl.cert, - key : config.ssl.key + keepAlive: true, + localAddress: config.proxy.localAddress, + rejectUnauthorized: config.ssl.strict, + ca: config.ssl.ca, + cert: config.ssl.certificate, + key: config.ssl.key }) } return httpsAgent - } - else { + } else { if (!httpAgent) { httpAgent = new HttpAgent({ - keepAlive : true, - localAddress : config.proxy.localAddress + keepAlive: true, + localAddress: config.proxy.localAddress }) } |