summaryrefslogtreecommitdiff
path: root/deps/npm/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-12-25 19:15:23 -0800
committerisaacs <i@izs.me>2013-12-25 19:15:23 -0800
commit7f82faee307de546a91c647086a0bb0c36de3132 (patch)
treeaf0051f131829ace07b4c782b79f9d07a3c56383 /deps/npm/lib
parent55b0bd639dea3e0d56b596aaa6ba2d26458c2be1 (diff)
downloadnode-new-7f82faee307de546a91c647086a0bb0c36de3132.tar.gz
npm: Upgrade to v1.3.22
Diffstat (limited to 'deps/npm/lib')
-rw-r--r--deps/npm/lib/adduser.js6
-rw-r--r--deps/npm/lib/bugs.js60
-rw-r--r--deps/npm/lib/cache.js4
-rw-r--r--deps/npm/lib/docs.js2
-rw-r--r--deps/npm/lib/install.js2
-rw-r--r--deps/npm/lib/utils/error-handler.js3
6 files changed, 51 insertions, 26 deletions
diff --git a/deps/npm/lib/adduser.js b/deps/npm/lib/adduser.js
index a5b9321d3e..f0a58555ec 100644
--- a/deps/npm/lib/adduser.js
+++ b/deps/npm/lib/adduser.js
@@ -18,9 +18,9 @@ function adduser (args, cb) {
if (!crypto) return cb(new Error(
"You must compile node with ssl support to use the adduser feature"))
- var c = { u : npm.config.get("username")
- , p : npm.config.get("_password")
- , e : npm.config.get("email")
+ var c = { u : npm.config.get("username") || ""
+ , p : npm.config.get("_password") || ""
+ , e : npm.config.get("email") || ""
}
, changed = false
, u = {}
diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js
index bcbf2bebb1..604748a97b 100644
--- a/deps/npm/lib/bugs.js
+++ b/deps/npm/lib/bugs.js
@@ -7,6 +7,9 @@ var npm = require("./npm.js")
, registry = npm.registry
, log = require("npmlog")
, opener = require("opener")
+ , path = require("path")
+ , readJson = require("read-package-json")
+ , fs = require("fs")
bugs.completion = function (opts, cb) {
if (opts.conf.argv.remain.length > 2) return cb()
@@ -16,28 +19,43 @@ bugs.completion = function (opts, cb) {
}
function bugs (args, cb) {
- if (!args.length) return cb(bugs.usage)
- var n = args[0].split("@").shift()
+ var n = args.length && args[0].split("@").shift() || '.'
+ fs.stat(n, function (er, s) {
+ if (er && er.code === "ENOENT") return callRegistry(n, cb)
+ else if (er) return cb (er)
+ if (!s.isDirectory()) return callRegistry(n, cb)
+ readJson(path.resolve(n, "package.json"), function(er, d) {
+ if (er) return cb(err)
+ getUrlAndOpen(d, cb)
+ })
+ })
+}
+
+function getUrlAndOpen (d, cb) {
+ var bugs = d.bugs
+ , repo = d.repository || d.repositories
+ , url
+ if (bugs) {
+ url = (typeof url === "string") ? bugs : bugs.url
+ } else if (repo) {
+ if (Array.isArray(repo)) repo = repo.shift()
+ if (repo.hasOwnProperty("url")) repo = repo.url
+ log.verbose("repository", repo)
+ if (bugs && bugs.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) {
+ url = bugs.replace(/^git(@|:\/\/)/, "https://")
+ .replace(/^https?:\/\/github.com:/, "https://github.com/")
+ .replace(/\.git$/, '')+"/issues"
+ }
+ }
+ if (!url) {
+ url = "https://npmjs.org/package/" + d.name
+ }
+ opener(url, { command: npm.config.get("browser") }, cb)
+}
+
+function callRegistry (n, cb) {
registry.get(n + "/latest", 3600, function (er, d) {
if (er) return cb(er)
- var bugs = d.bugs
- , repo = d.repository || d.repositories
- , url
- if (bugs) {
- url = (typeof bugs === "string") ? bugs : bugs.url
- } else if (repo) {
- if (Array.isArray(repo)) repo = repo.shift()
- if (repo.hasOwnProperty("url")) repo = repo.url
- log.verbose("repository", repo)
- if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) {
- url = repo.replace(/^git(@|:\/\/)/, "https://")
- .replace(/^https?:\/\/github.com:/, "https://github.com/")
- .replace(/\.git$/, '')+"/issues"
- }
- }
- if (!url) {
- url = "https://npmjs.org/package/" + d.name
- }
- opener(url, { command: npm.config.get("browser") }, cb)
+ getUrlAndOpen (d, cb)
})
}
diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js
index b606ef2517..c182817e4f 100644
--- a/deps/npm/lib/cache.js
+++ b/deps/npm/lib/cache.js
@@ -287,6 +287,10 @@ function fetchAndShaCheck (u, tmp, shasum, cb) {
if (!shasum) return cb(null, response)
// validate that the url we just downloaded matches the expected shasum.
sha.check(tmp, shasum, function (er) {
+ if (er != null && er.message) {
+ // add original filename for better debuggability
+ er.message = er.message + '\n' + 'From: ' + u
+ }
return cb(er, response, shasum)
})
})
diff --git a/deps/npm/lib/docs.js b/deps/npm/lib/docs.js
index b48646a56f..0f59572ac8 100644
--- a/deps/npm/lib/docs.js
+++ b/deps/npm/lib/docs.js
@@ -25,7 +25,7 @@ function docs (args, cb) {
var project = args[0] || '.'
, package = path.resolve(process.cwd(), "package.json")
- if (project === '.') {
+ if (project === '.' || project === './') {
try {
var json = require(package)
if (!json.name) throw new Error('package.json does not have a valid "name" property')
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index fe210764cc..f408985a4c 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -714,7 +714,7 @@ function targetResolver (where, context, deps) {
}
if (data && !data._from) data._from = what
-
+ if (er && parent && parent.name) er.parent = parent.name
return cb(er, data || [])
})
}
diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js
index 076449a5f3..93d8792e98 100644
--- a/deps/npm/lib/utils/error-handler.js
+++ b/deps/npm/lib/utils/error-handler.js
@@ -149,6 +149,9 @@ function errorHandler (er) {
if (er.pkgid && er.pkgid !== "-") {
var msg = ["'"+er.pkgid+"' is not in the npm registry."
,"You should bug the author to publish it"]
+ if (er.parent) {
+ msg.push("It was specified as a dependency of '"+er.parent+"'")
+ }
if (er.pkgid.match(/^node[\.\-]|[\.\-]js$/)) {
var s = er.pkgid.replace(/^node[\.\-]|[\.\-]js$/g, "")
if (s !== er.pkgid) {