Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bugs.js')
-rw-r--r--lib/bugs.js40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/bugs.js b/lib/bugs.js
index 16744cd5c..ea27bdd82 100644
--- a/lib/bugs.js
+++ b/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,10 +14,10 @@ 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 || [])
})
})
@@ -27,8 +26,10 @@ bugs.completion = function (opts, cb) {
function bugs (args, cb) {
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)
})
})
}