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>2014-08-30 02:06:19 +0400
committerisaacs <i@izs.me>2014-08-30 02:43:30 +0400
commit0602f708f070d524ad41573afd4c57171cab21ad (patch)
tree23e433a5435c37202971c7984dcc91a7c4914846 /lib
parent6b201dc4a170e442b38503a8df1968788a82e839 (diff)
ls: Do not show deps of extraneous deps
Fix #6064
Diffstat (limited to 'lib')
-rw-r--r--lib/ls.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/ls.js b/lib/ls.js
index 2310dedb4..ed329d19e 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -39,6 +39,7 @@ function ls (args, silent, cb) {
var depth = npm.config.get("depth")
var opt = { depth: depth, log: log.warn, dev: true }
readInstalled(dir, opt, function (er, data) {
+ pruneNestedExtraneous(data)
var bfs = bfsify(data, args)
, lite = getLite(bfs)
@@ -75,6 +76,18 @@ function ls (args, silent, cb) {
})
}
+function pruneNestedExtraneous (data, visited) {
+ visited = visited || []
+ visited.push(data)
+ for (var i in data.dependencies) {
+ if (data.dependencies[i].extraneous) {
+ data.dependencies[i].dependencies = {}
+ } else if (visited.indexOf(data.dependencies[i]) === -1) {
+ pruneNestedExtraneous(data.dependencies[i], visited)
+ }
+ }
+}
+
function alphasort (a, b) {
a = a.toLowerCase()
b = b.toLowerCase()