diff options
author | isaacs <i@izs.me> | 2014-08-30 02:06:19 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-08-30 02:43:30 +0400 |
commit | 0602f708f070d524ad41573afd4c57171cab21ad (patch) | |
tree | 23e433a5435c37202971c7984dcc91a7c4914846 /lib | |
parent | 6b201dc4a170e442b38503a8df1968788a82e839 (diff) |
ls: Do not show deps of extraneous deps
Fix #6064
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ls.js | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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() |