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-03-11 02:29:42 +0300
committerisaacs <i@izs.me>2011-03-22 01:56:00 +0300
commit1abdee681af64d7a9fd085f0b42f6e893576b130 (patch)
tree8eb2db3d3cb4a5135987e02180cbe7adc41a229c /lib/prune.js
parent13411e48a30d2457feca897ebb535f5c6f96d04c (diff)
Prune would get confused by link packages
Diffstat (limited to 'lib/prune.js')
-rw-r--r--lib/prune.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/prune.js b/lib/prune.js
index d2aae8b4a..8217c3a1d 100644
--- a/lib/prune.js
+++ b/lib/prune.js
@@ -15,18 +15,22 @@ function prune (args, cb) {
}
function prune_ (args, data, cb) {
- npm.commands.unbuild(prunables(args, data), cb)
+ npm.commands.unbuild(prunables(args, data, []), cb)
}
-function prunables (args, data, cb) {
+function prunables (args, data, seen) {
var deps = data.dependencies || {}
return Object.keys(deps).map(function (d) {
- if (typeof deps[d] !== "object") return null
+ if (typeof deps[d] !== "object"
+ || seen.indexOf(deps[d]) !== -1) return null
+ seen.push(deps[d])
if (deps[d].extraneous
&& (args.length === 0 || args.indexOf(d) !== -1)) {
- return deps[d].path
+ var extra = deps[d]
+ delete deps[d]
+ return extra.path
}
- return prunables(args, deps[d])
+ return prunables(args, deps[d], seen)
}).filter(function (d) { return d !== null })
.reduce(function FLAT (l, r) {
return l.concat(Array.isArray(r) ? r.reduce(FLAT,[]) : r)