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/npm.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-10-30 01:07:09 +0400
committerisaacs <i@izs.me>2010-10-30 01:07:09 +0400
commite80b54efc1b4ca3029ae6b0ca32e631bc87951f8 (patch)
treeec43b9fe66a897e3a9fa1e784769fc96aa4d64c4 /npm.js
parent4c759ea50f2c718e09cc7a6f179d44fb27082cd8 (diff)
Add an 'npm complete' command to look up aliases
Diffstat (limited to 'npm.js')
-rw-r--r--npm.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/npm.js b/npm.js
index 8d8cc34cc..f666b4c2d 100644
--- a/npm.js
+++ b/npm.js
@@ -83,12 +83,21 @@ var commandCache = {}
Object.keys(abbrevs).forEach(function (c) {
Object.defineProperty(npm.commands, c, { get : function () {
- var a = abbrevs[c]
- if (aliases[a]) a = aliases[a]
+ var a = complete(c)
if (commandCache[a]) return commandCache[a]
return commandCache[a] = require(__dirname+"/lib/"+a)
}, enumerable: fullList.indexOf(c) !== -1 })
})
+function complete (c) {
+ var a = abbrevs[c]
+ if (aliases[a]) a = aliases[a]
+ return a
+}
+npm.commands.complete = function (args, cb_) {
+ var a = complete(args[0])
+ function cb (e) { cb_(e, a) }
+ require("./lib/utils/output").write(npm.config.get("outfd"), a, cb)
+}
var loaded = false
npm.load = function (conf, cb_) {