4 repo.usage = "npm repo <pkgname>"
6 repo.completion = function (opts, cb) {
7 if (opts.conf.argv.remain.length > 2) return cb()
8 registry.get("/-/short", 60000, function (er, list) {
9 return cb(null, list || [])
13 var npm = require("./npm.js")
14 , registry = npm.registry
15 , log = require("npmlog")
16 , opener = require("opener")
17 , github = require('github-url-from-git')
18 , githubUserRepo = require("github-url-from-username-repo")
20 function repo (args, cb) {
21 if (!args.length) return cb(repo.usage)
22 var n = args[0].split("@").shift()
23 registry.get(n + "/latest", 3600, function (er, d) {
26 if (!r) return cb(new Error('no repository'));
27 // XXX remove this when npm@v1.3.10 from node 0.10 is deprecated
28 // from https://github.com/isaacs/npm-www/issues/418
29 if (githubUserRepo(r.url))
30 r.url = githubUserRepo(r.url)
32 var url = github(r.url)
34 return cb(new Error('no repository: could not get url'))
35 opener(url, { command: npm.config.get("browser") }, cb)