diff options
Diffstat (limited to 'lib/ls.js')
-rw-r--r-- | lib/ls.js | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -40,6 +40,7 @@ function ls (args, silent, cb) { var opt = { depth: depth, log: log.warn, dev: true } readInstalled(dir, opt, function (er, data) { pruneNestedExtraneous(data) + filterByEnv(data) var bfs = bfsify(data, args) , lite = getLite(bfs) @@ -88,6 +89,21 @@ function pruneNestedExtraneous (data, visited) { } } +function filterByEnv (data) { + var dev = npm.config.get("dev") + var production = npm.config.get("production") + if (dev === production) return + var dependencies = {} + var devDependencies = data.devDependencies || [] + Object.keys(data.dependencies).forEach(function (name) { + var keys = Object.keys(devDependencies) + if (production && keys.indexOf(name) !== -1) return + if (dev && keys.indexOf(name) === -1) return + dependencies[name] = data.dependencies[name] + }) + data.dependencies = dependencies +} + function alphasort (a, b) { a = a.toLowerCase() b = b.toLowerCase() |