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
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-02-26 04:18:21 +0300
committerisaacs <i@izs.me>2011-02-26 04:18:21 +0300
commit7431b8a8999be98f49396efcce1607e4223fbd38 (patch)
tree083afdefd8169a7d569778417ee25f4db2d769fa
parent363117ef97432c33443d3b04a5fedcd309fe0abc (diff)
Close GH-537 Add --listexclude config
-rw-r--r--doc/config.md10
-rw-r--r--lib/ls.js17
-rw-r--r--lib/utils/default-config.js1
-rw-r--r--lib/utils/parse-args.js1
-rw-r--r--man1/config.111
-rw-r--r--man1/get.111
-rw-r--r--man1/set.111
7 files changed, 60 insertions, 2 deletions
diff --git a/doc/config.md b/doc/config.md
index 870ff2558..6f0db6c28 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -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: ""
diff --git a/lib/ls.js b/lib/ls.js
index 0e5c90326..de0cc52fd 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -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)
diff --git a/lib/utils/default-config.js b/lib/utils/default-config.js
index 51f8ed446..6651c1b80 100644
--- a/lib/utils/default-config.js
+++ b/lib/utils/default-config.js
@@ -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")
diff --git a/lib/utils/parse-args.js b/lib/utils/parse-args.js
index bd90dec50..1156b9d90 100644
--- a/lib/utils/parse-args.js
+++ b/lib/utils/parse-args.js
@@ -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
diff --git a/man1/config.1 b/man1/config.1
index 66c446114..1f9826566 100644
--- a/man1/config.1
+++ b/man1/config.1
@@ -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: ""
.
diff --git a/man1/get.1 b/man1/get.1
index 66c446114..1f9826566 100644
--- a/man1/get.1
+++ b/man1/get.1
@@ -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: ""
.
diff --git a/man1/set.1 b/man1/set.1
index 66c446114..1f9826566 100644
--- a/man1/set.1
+++ b/man1/set.1
@@ -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: ""
.