diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-11-21 09:48:45 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-11-21 10:50:52 -0800 |
commit | b488be127a8cf1e59eb257db3f8eaf6efdb0f275 (patch) | |
tree | 83436f4f84b9651ea66c3a0d304050252916c149 /deps/npm/lib/bugs.js | |
parent | 05de01d707cd9a80f34da23445f507f5f2e2c277 (diff) | |
download | node-new-b488be127a8cf1e59eb257db3f8eaf6efdb0f275.tar.gz |
Include NPM, update .pkg to install it.
.msi update coming soon.
Diffstat (limited to 'deps/npm/lib/bugs.js')
-rw-r--r-- | deps/npm/lib/bugs.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js new file mode 100644 index 0000000000..1c52ffda0e --- /dev/null +++ b/deps/npm/lib/bugs.js @@ -0,0 +1,50 @@ + +module.exports = bugs + +bugs.usage = "npm bugs <pkgname>" + +bugs.completion = function (opts, cb) { + if (opts.conf.argv.remain.length > 2) return cb() + registry.get("/-/short", null, 60000, function (er, list) { + return cb(null, list || []) + }) +} + +var exec = require("./utils/exec.js") + , registry = require("./utils/npm-registry-client/index.js") + , npm = require("./npm.js") + , log = require("./utils/log.js") + +function bugs (args, cb) { + if (!args.length) return cb(bugs.usage) + var n = args[0].split("@").shift() + registry.get(n, "latest", 3600, function (er, d) { + if (er) return cb(er) + var bugs = d.bugs + , repo = d.repository || d.repositories + if (bugs) { + if (typeof bugs === "string") return open(bugs, cb) + if (bugs.url) return open(bugs.url, cb) + } + if (repo) { + if (Array.isArray(repo)) repo = repo.shift() + if (repo.url) repo = repo.url + log.verbose(repo, "repository") + if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) { + return open(repo.replace(/^git(@|:\/\/)/, "http://") + .replace(/^https?:\/\/github.com:/, "github.com/") + .replace(/\.git$/, '')+"/issues", cb) + } + } + return open("http://search.npmjs.org/#/" + d.name, cb) + }) +} + +function open (url, cb) { + exec(npm.config.get("browser"), [url], log.er(cb, + "Failed to open "+url+" in a browser. It could be that the\n"+ + "'browser' config is not set. Try doing this:\n"+ + " npm config set browser google-chrome\n"+ + "or:\n"+ + " npm config set browser lynx\n")) +} |