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/ls.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ls.js')
-rw-r--r--lib/ls.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ls.js b/lib/ls.js
index eee4f2772..05166ee6a 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -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()