Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added auto completion of local bin.

  • Loading branch information...
commit c97580ab26f9047ed1fdee1d5c2582a8db0b52c0 1 parent 646a676
@beefsack authored
Showing with 22 additions and 2 deletions.
  1. +3 −2 lib/exec.js
  2. +19 −0 lib/utils/completion/local-bin.js
View
5 lib/exec.js
@@ -5,9 +5,10 @@ var npm = require("./npm.js")
exec.usage = "npm exec <command>\n(execute command using local package bin)"
+exec.completion = require("./utils/completion/local-bin.js")
+
function exec (args, cb) {
- var path = require("path")
- , b = npm.bin
+ var b = npm.bin
, exec = require("child_process").exec
if (args.length == 0) return cb("Usage:\n"+exec.usage)
View
19 lib/utils/completion/local-bin.js
@@ -0,0 +1,19 @@
+module.exports = localBin
+
+var npm = require("../../npm.js")
+ , find = require("../find.js")
+ , path = require("path")
+
+function localBin (filter, cb) {
+ var b = npm.bin;
+ path.exists(b, function(exists) {
+ // Return if there is no local bin dir
+ if (!exists) return cb(null, [])
+ // Search local bin for files
+ find(b, null, 1, function(er, files) {
+ return cb(null, (files || []).map(function(f) {
+ return f.replace(b + '/', '')
+ }))
+ })
+ })
+}
Please sign in to comment.
Something went wrong with that request. Please try again.