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:
authorTJ Holowaychuk <tj@vision-media.ca>2013-07-05 03:34:45 +0400
committerDomenic Denicola <domenic@domenicdenicola.com>2013-08-16 03:47:43 +0400
commit0223389130dfd220d2a18dfe7058c4f7f0b14808 (patch)
treed79c91c25999595d36be78c45d121c37f761763f /lib/repo.js
parentb17e07c4cc95bf99b6586ab3a3fd3aca3d8a8d39 (diff)
add "repo" command
Diffstat (limited to 'lib/repo.js')
-rw-r--r--lib/repo.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/repo.js b/lib/repo.js
new file mode 100644
index 000000000..19066c822
--- /dev/null
+++ b/lib/repo.js
@@ -0,0 +1,29 @@
+
+module.exports = repo
+
+repo.usage = "npm repo <pkgname>"
+
+repo.completion = function (opts, cb) {
+ if (opts.conf.argv.remain.length > 2) return cb()
+ registry.get("/-/short", 60000, function (er, list) {
+ return cb(null, list || [])
+ })
+}
+
+var npm = require("./npm.js")
+ , registry = npm.registry
+ , log = require("npmlog")
+ , opener = require("opener")
+ , github = require('github-url-from-git')
+
+function repo (args, cb) {
+ if (!args.length) return cb(repo.usage)
+ var n = args[0].split("@").shift()
+ registry.get(n + "/latest", 3600, function (er, d) {
+ if (er) return cb(er)
+ var r = d.repository;
+ if (!r) return cb(new Error('no repository'));
+ var url = github(r.url);
+ opener(url, { command: npm.config.get("browser") }, cb)
+ })
+}