diff options
author | Forrest L Norvell <ogd@aoaioxxysz.net> | 2015-01-08 14:37:26 -0800 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-01-08 23:49:03 +0100 |
commit | e79ccee1685393e4ec73746bac93835cbcf3a809 (patch) | |
tree | 304a1ddd59495b50a20d1b25c62da2a4519228db /deps/npm/lib/bugs.js | |
parent | 156cd82ef4d2ff4fa291407de562c3a7c2386dc7 (diff) | |
download | android-node-v8-e79ccee1685393e4ec73746bac93835cbcf3a809.tar.gz android-node-v8-e79ccee1685393e4ec73746bac93835cbcf3a809.tar.bz2 android-node-v8-e79ccee1685393e4ec73746bac93835cbcf3a809.zip |
npm: upgrade to v2.1.18
PR-URL: https://github.com/iojs/io.js/pull/266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/npm/lib/bugs.js')
-rw-r--r-- | deps/npm/lib/bugs.js | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js index 16744cd5c8..fabbbaf10e 100644 --- a/deps/npm/lib/bugs.js +++ b/deps/npm/lib/bugs.js @@ -4,7 +4,6 @@ module.exports = bugs bugs.usage = "npm bugs <pkgname>" var npm = require("./npm.js") - , registry = npm.registry , log = require("npmlog") , opener = require("opener") , path = require("path") @@ -15,20 +14,22 @@ var npm = require("./npm.js") bugs.completion = function (opts, cb) { if (opts.conf.argv.remain.length > 2) return cb() - mapToRegistry("-/short", npm.config, function (er, uri) { + mapToRegistry("-/short", npm.config, function (er, uri, auth) { if (er) return cb(er) - registry.get(uri, { timeout : 60000 }, function (er, list) { + npm.registry.get(uri, { timeout : 60000, auth : auth }, function (er, list) { return cb(null, list || []) }) }) } function bugs (args, cb) { - var n = args.length && npa(args[0]).name || '.' + var n = args.length && npa(args[0]).name || "." fs.stat(n, function (er, s) { - if (er && er.code === "ENOENT") return callRegistry(n, cb) - else if (er) return cb (er) + if (er) { + if (er.code === "ENOENT") return callRegistry(n, cb) + return cb(er) + } if (!s.isDirectory()) return callRegistry(n, cb) readJson(path.resolve(n, "package.json"), function(er, d) { if (er) return cb(er) @@ -38,35 +39,36 @@ function bugs (args, cb) { } function getUrlAndOpen (d, cb) { - var bugs = d.bugs - , repo = d.repository || d.repositories + var repo = d.repository || d.repositories , url - if (bugs) { - url = (typeof url === "string") ? bugs : bugs.url - } else if (repo) { + if (d.bugs) { + url = (typeof d.bugs === "string") ? d.bugs : d.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://") + log.verbose("bugs", "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" + .replace(/\.git$/, "")+"/issues" } } if (!url) { - url = "https://npmjs.org/package/" + d.name + url = "https://www.npmjs.org/package/" + d.name } + log.silly("bugs", "url", url) opener(url, { command: npm.config.get("browser") }, cb) } -function callRegistry (n, cb) { - mapToRegistry(n, npm.config, function (er, uri) { +function callRegistry (name, cb) { + mapToRegistry(name, npm.config, function (er, uri, auth) { if (er) return cb(er) - registry.get(uri + "/latest", { timeout : 3600 }, function (er, d) { + npm.registry.get(uri + "/latest", { auth : auth }, function (er, d) { if (er) return cb(er) - getUrlAndOpen (d, cb) + getUrlAndOpen(d, cb) }) }) } |