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
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-03-23 04:16:56 +0300
committerisaacs <i@izs.me>2011-03-23 04:16:56 +0300
commitea1dd644d11f605e3d53ae3f6de690a226dd05cb (patch)
tree037a9e42ffd01d0f7b475ae41579f6e190c625dd /lib
parent8537bce078db642a62c73bd595444167730029b3 (diff)
complete install command against versions as well as name
Diffstat (limited to 'lib')
-rw-r--r--lib/install.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/install.js b/lib/install.js
index b39e6180e..cee479baa 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -106,7 +106,23 @@ install.completion = function (opts, cb) {
// if it starts with https?://, then just give up, because it's a url
// for now, not yet implemented.
var registry = require("./utils/npm-registry-client")
- return registry.get("/-/short", cb)
+ registry.get("/-/short", function (er, pkgs) {
+ if (er) return cb()
+ if (!opts.partialWord) return cb(null, pkgs)
+ var name = opts.partialWord.split("@").shift()
+ pkgs = pkgs.filter(function (p) {
+ return p.indexOf(name) === 0
+ })
+ if (pkgs.length !== 1 && opts.partialWord === name) return cb(null, pkgs)
+ registry.get(pkgs[0], function (er, d) {
+ if (er) return cb()
+ return cb(null, Object.keys(d["dist-tags"] || {})
+ .concat(Object.keys(d.versions || {}))
+ .map(function (t) {
+ return pkgs[0] + "@" + t
+ }))
+ })
+ })
}
var npm = require("../npm")