summaryrefslogtreecommitdiff
path: root/deps/npm/lib/docs.js
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-09-24 14:41:07 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-09-24 17:15:10 -0700
commit9fad8958df671c0e894506ef59b4c781c3dfb349 (patch)
tree4db7643b40c4ffd726fb27fb4aa276d420b3bfd8 /deps/npm/lib/docs.js
parentb26dd4e5ab9192bad72b9dc61fa4ad2d8f215da2 (diff)
downloadandroid-node-v8-9fad8958df671c0e894506ef59b4c781c3dfb349.tar.gz
android-node-v8-9fad8958df671c0e894506ef59b4c781c3dfb349.tar.bz2
android-node-v8-9fad8958df671c0e894506ef59b4c781c3dfb349.zip
deps: upgrade npm to 2.0.0
Diffstat (limited to 'deps/npm/lib/docs.js')
-rw-r--r--deps/npm/lib/docs.js26
1 files changed, 17 insertions, 9 deletions
diff --git a/deps/npm/lib/docs.js b/deps/npm/lib/docs.js
index 77073fbb9c..dead3f7551 100644
--- a/deps/npm/lib/docs.js
+++ b/deps/npm/lib/docs.js
@@ -5,18 +5,21 @@ docs.usage += "\n"
docs.usage += "npm docs ."
docs.completion = function (opts, cb) {
- var uri = url_.resolve(npm.config.get("registry"), "/-/short")
- registry.get(uri, { timeout : 60000 }, function (er, list) {
- return cb(null, list || [])
+ mapToRegistry("/-/short", npm.config, function (er, uri) {
+ if (er) return cb(er)
+
+ registry.get(uri, { timeout : 60000 }, function (er, list) {
+ return cb(null, list || [])
+ })
})
}
-var url_ = require("url")
- , npm = require("./npm.js")
+var npm = require("./npm.js")
, registry = npm.registry
, opener = require("opener")
, path = require("path")
, log = require("npmlog")
+ , mapToRegistry = require("./utils/map-to-registry.js")
function url (json) {
return json.homepage ? json.homepage : "https://npmjs.org/package/" + json.name
@@ -38,7 +41,7 @@ function docs (args, cb) {
function getDoc (project, cb) {
project = project || '.'
- var package = path.resolve(process.cwd(), "package.json")
+ var package = path.resolve(npm.localPrefix, "package.json")
if (project === '.' || project === './') {
var json
@@ -54,8 +57,13 @@ function getDoc (project, cb) {
return opener(url(json), { command: npm.config.get("browser") }, cb)
}
- var uri = url_.resolve(npm.config.get("registry"), project + "/latest")
- registry.get(uri, { timeout : 3600 }, function (er, json) {
+ mapToRegistry(project, npm.config, function (er, uri) {
+ if (er) return cb(er)
+
+ registry.get(uri + "/latest", { timeout : 3600 }, next)
+ })
+
+ function next (er, json) {
var github = "https://github.com/" + project + "#readme"
if (er) {
@@ -64,5 +72,5 @@ function getDoc (project, cb) {
}
return opener(url(json), { command: npm.config.get("browser") }, cb)
- })
+ }
}