4 bugs.usage = "npm bugs <pkgname>"
6 var npm = require("./npm.js")
7 , registry = npm.registry
8 , log = require("npmlog")
9 , opener = require("opener")
11 bugs.completion = function (opts, cb) {
12 if (opts.conf.argv.remain.length > 2) return cb()
13 registry.get("/-/short", 60000, function (er, list) {
14 return cb(null, list || [])
18 function bugs (args, cb) {
19 if (!args.length) return cb(bugs.usage)
20 var n = args[0].split("@").shift()
21 registry.get(n + "/latest", 3600, function (er, d) {
24 , repo = d.repository || d.repositories
27 url = (typeof bugs === "string") ? bugs : bugs.url
29 if (Array.isArray(repo)) repo = repo.shift()
30 if (repo.hasOwnProperty("url")) repo = repo.url
31 log.verbose("repository", repo)
32 if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) {
33 url = repo.replace(/^git(@|:\/\/)/, "https://")
34 .replace(/^https?:\/\/github.com:/, "https://github.com/")
35 .replace(/\.git$/, '')+"/issues"
39 url = "https://npmjs.org/package/" + d.name
41 opener(url, { command: npm.config.get("browser") }, cb)