Permalink
Browse files

Close GH-537 Add --listexclude config

  • Loading branch information...
1 parent 363117e commit 7431b8a8999be98f49396efcce1607e4223fbd38 @isaacs isaacs committed Feb 26, 2011
Showing with 60 additions and 2 deletions.
  1. +10 −0 doc/config.md
  2. +15 −2 lib/ls.js
  3. +1 −0 lib/utils/default-config.js
  4. +1 −0 lib/utils/parse-args.js
  5. +11 −0 man1/config.1
  6. +11 −0 man1/get.1
  7. +11 −0 man1/set.1
View
@@ -329,6 +329,16 @@ Default: env.EDITOR
The program to use to edit files.
+### listexclude
+
+Default: null
+
+A whitespace separated list of strings which *prevent* items from being
+shown to `npm ls`.
+
+For example, `npm ls installed --listexclude zombie` will show all
+installed packages *except* zombie.
+
### listopts
Default: ""
View
@@ -44,9 +44,13 @@ function ls (args, silent, staleness, cb_) {
if (typeof cb_ !== "function") cb_ = staleness, staleness = 600
if (typeof cb_ !== "function") cb_ = silent, silent = false
var listopts = npm.config.get("listopts")
+ , listexclude = npm.config.get("listexclude")
if (typeof listopts !== "string") listopts = ""
listopts = listopts.split(/\s+/)
- getFilteredData(staleness, listopts.concat(args), function (er, data) {
+ if (typeof listexclude === "string") listexclude = listexclude.split(/\s+/)
+ else listexclude = []
+ getFilteredData( staleness, listopts.concat(args), listexclude
+ , function (er, data) {
// now data is the list of data that we want to show.
// prettify and print it, and then provide the raw
// data to the cb.
@@ -57,7 +61,7 @@ function ls (args, silent, staleness, cb_) {
})
}
-function getFilteredData (staleness, args, cb) {
+function getFilteredData (staleness, args, notArgs, cb) {
var processedData = {}
, includeRemote = args.indexOf("installed") === -1
getMergedData(staleness, includeRemote, function (er, data) {
@@ -91,6 +95,15 @@ function getFilteredData (staleness, args, cb) {
}
if (!pass) break
}
+ if (pass) for (var i = 0, l = notArgs.length; i < l; i ++) {
+ for (var ii = 0, ll = test.length; ii < ll; ii ++) {
+ if (test[ii].indexOf(notArgs[i]) !== -1) {
+ pass = false
+ break
+ }
+ }
+ if (!pass) break
+ }
if (pass) filtered[name] = d
})
return cb(null, filtered)
@@ -30,6 +30,7 @@ module.exports =
, group : process.env.SUDO_GID || process.getgid()
, gzipbin : process.env.GZIPBIN || "gzip"
, listopts: ""
+ , listexclude: null
, logfd : stdio.stderrFD
, loglevel : "info"
, manroot : path.join(process.execPath, "..", "..", "share", "man")
View
@@ -31,6 +31,7 @@ exports.types =
, group : String
, gzipbin : String
, listopts : String
+ , listexclude: [null, String]
, logfd : [Number, Stream]
, loglevel : ["silent","win","error","warn","info","verbose","silly"]
, manroot : path
View
@@ -428,6 +428,17 @@ Default: env\.EDITOR
.P
The program to use to edit files\.
.
+.SS "listexclude"
+Default: null
+.
+.P
+A whitespace separated list of strings which \fIprevent\fR items from being
+shown to \fBnpm ls\fR\|\.
+.
+.P
+For example, \fBnpm ls installed \-\-listexclude zombie\fR will show all
+installed packages \fIexcept\fR zombie\.
+.
.SS "listopts"
Default: ""
.
View
@@ -428,6 +428,17 @@ Default: env\.EDITOR
.P
The program to use to edit files\.
.
+.SS "listexclude"
+Default: null
+.
+.P
+A whitespace separated list of strings which \fIprevent\fR items from being
+shown to \fBnpm ls\fR\|\.
+.
+.P
+For example, \fBnpm ls installed \-\-listexclude zombie\fR will show all
+installed packages \fIexcept\fR zombie\.
+.
.SS "listopts"
Default: ""
.
View
@@ -428,6 +428,17 @@ Default: env\.EDITOR
.P
The program to use to edit files\.
.
+.SS "listexclude"
+Default: null
+.
+.P
+A whitespace separated list of strings which \fIprevent\fR items from being
+shown to \fBnpm ls\fR\|\.
+.
+.P
+For example, \fBnpm ls installed \-\-listexclude zombie\fR will show all
+installed packages \fIexcept\fR zombie\.
+.
.SS "listopts"
Default: ""
.

0 comments on commit 7431b8a

Please sign in to comment.