summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/index.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/index.js75
1 files changed, 37 insertions, 38 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/index.js b/deps/npm/node_modules/npm-registry-client/index.js
index a75e8bbdb..801d00f8e 100644
--- a/deps/npm/node_modules/npm-registry-client/index.js
+++ b/deps/npm/node_modules/npm-registry-client/index.js
@@ -2,56 +2,55 @@
module.exports = RegClient
-var url = require('url')
-, npmlog
-, cacheFile = require('npm-cache-filename')
+var join = require("path").join
+ , fs = require("graceful-fs")
+var npmlog
try {
npmlog = require("npmlog")
-} catch (er) {
- npmlog = { error: noop, warn: noop, info: noop,
- verbose: noop, silly: noop, http: noop,
- pause: noop, resume: noop }
+}
+catch (er) {
+ npmlog = {
+ error : noop,
+ warn : noop,
+ info : noop,
+ verbose : noop,
+ silly : noop,
+ http : noop,
+ pause : noop,
+ resume : noop
+ }
}
function noop () {}
-function RegClient (conf) {
- // accept either a plain-jane object, or a npmconf object
- // with a "get" method.
- if (typeof conf.get !== 'function') {
- var data = conf
- conf = { get: function (k) { return data[k] }
- , set: function (k, v) { data[k] = v }
- , del: function (k) { delete data[k] } }
- }
+function RegClient (config) {
+ this.config = Object.create(config || {})
- this.conf = conf
-
- // if provided, then the registry needs to be a url.
- // if it's not provided, then we're just using the cache only.
- var registry = conf.get('registry')
- if (registry) {
- registry = url.parse(registry)
- if (!registry.protocol) throw new Error(
- 'Invalid registry: ' + registry.url)
- registry = registry.href
- if (registry.slice(-1) !== '/') {
- registry += '/'
- }
- this.conf.set('registry', registry)
- } else {
- registry = null
+ this.config.proxy = this.config.proxy || {}
+ if (!this.config.proxy.https && this.config.proxy.http) {
+ this.config.proxy.https = this.config.proxy.http
}
- this.registry = registry
+ this.config.ssl = this.config.ssl || {}
+ if (this.config.ssl.strict === undefined) this.config.ssl.strict = true
+
+ this.config.retry = this.config.retry || {}
+ if (typeof this.config.retry.retries !== "number") this.config.retry.retries = 2
+ if (typeof this.config.retry.factor !== "number") this.config.retry.factor = 10
+ if (typeof this.config.retry.minTimeout !== "number") this.config.retry.minTimeout = 10000
+ if (typeof this.config.retry.maxTimeout !== "number") this.config.retry.maxTimeout = 60000
+
+ this.config.userAgent = this.config.userAgent || "node/" + process.version
+ this.config.defaultTag = this.config.defaultTag || "latest"
- if (!conf.get('cache')) throw new Error("Cache dir is required")
- this.cacheFile = cacheFile(this.conf.get('cache'))
- this.log = conf.log || conf.get('log') || npmlog
+ this.log = this.config.log || npmlog
+ delete this.config.log
}
-require('fs').readdirSync(__dirname + "/lib").forEach(function (f) {
+fs.readdirSync(join(__dirname, "lib")).forEach(function (f) {
if (!f.match(/\.js$/)) return
- RegClient.prototype[f.replace(/\.js$/, '')] = require('./lib/' + f)
+ var name = f.replace(/\.js$/, "")
+ .replace(/-([a-z])/, function (_, l) { return l.toUpperCase() })
+ RegClient.prototype[name] = require(join(__dirname, "lib", f))
})