diff options
author | isaacs <i@izs.me> | 2010-10-30 01:07:09 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-10-30 01:07:09 +0400 |
commit | e80b54efc1b4ca3029ae6b0ca32e631bc87951f8 (patch) | |
tree | ec43b9fe66a897e3a9fa1e784769fc96aa4d64c4 /npm.js | |
parent | 4c759ea50f2c718e09cc7a6f179d44fb27082cd8 (diff) |
Add an 'npm complete' command to look up aliases
Diffstat (limited to 'npm.js')
-rw-r--r-- | npm.js | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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_) { |