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-22 19:14:52 +0300
committerisaacs <i@izs.me>2011-03-22 19:14:52 +0300
commitb9e41369dabe89a437c4c673fb3048c5fb206d69 (patch)
treef5b71580ad18262299d735533dda25407f410009 /lib
parent79f7cf0034baae1a73c7c92fa2a6102672554768 (diff)
completion on completion
Diffstat (limited to 'lib')
-rw-r--r--lib/completion.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/completion.js b/lib/completion.js
index 613b789ba..b1f9db35d 100644
--- a/lib/completion.js
+++ b/lib/completion.js
@@ -15,6 +15,34 @@ var output = require("./utils/output")
, stdio = process.binding("stdio")
, npm = require("../npm")
+completion.completion = function (opts, cb) {
+ if (opts.w > 3) return cb()
+
+ var fs = require("fs")
+ , path = require("path")
+ , bashExists = null
+ , zshExists = null
+ , bashProfExists = null
+ fs.stat(path.resolve(process.env.HOME, ".bashrc"), function (er, b) {
+ bashExists = !er
+ next()
+ })
+ fs.stat(path.resolve(process.env.HOME, ".zshrc"), function (er, b) {
+ zshExists = !er
+ next()
+ })
+ function next () {
+ if (zshExists === null || bashExists === null) return
+ var out = []
+ if (zshExists) out.push("~/.zshrc")
+ if (bashExists) out.push("~/.bashrc")
+ if (opts.w === 2) out = out.map(function (m) {
+ return [">>", m]
+ })
+ cb(null, out)
+ }
+}
+
function completion (args, cb) {
// if the COMP_* isn't in the env, then just dump the script.
if (process.env.COMP_CWORD === undefined