Revision 5aef65a9 deps/npm/lib/dedupe.js
deps/npm/lib/dedupe.js | ||
---|---|---|
35 | 35 |
|
36 | 36 |
function dedupe_ (dir, filter, unavoidable, dryrun, silent, cb) { |
37 | 37 |
readInstalled(path.resolve(dir), {}, null, function (er, data, counter) { |
38 |
if (er) { |
|
39 |
return cb(er) |
|
40 |
} |
|
41 |
|
|
42 |
if (!data) { |
|
43 |
return cb() |
|
44 |
} |
|
45 |
|
|
38 | 46 |
// find out which things are dupes |
39 |
var dupes = Object.keys(counter).filter(function (k) { |
|
47 |
var dupes = Object.keys(counter || {}).filter(function (k) {
|
|
40 | 48 |
if (filter.length && -1 === filter.indexOf(k)) return false |
41 | 49 |
return counter[k] > 1 && !unavoidable[k] |
42 | 50 |
}).reduce(function (s, k) { |
... | ... | |
265 | 273 |
}) |
266 | 274 |
|
267 | 275 |
readJson(path.resolve(dir, "package.json"), function (er, data) { |
268 |
if (er && er.code !== "ENOENT") return cb(er) |
|
276 |
if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er)
|
|
269 | 277 |
if (er) return cb() // not a package, probably. |
270 | 278 |
counter[data.name] = counter[data.name] || 0 |
271 | 279 |
counter[data.name]++ |
... | ... | |
294 | 302 |
|
295 | 303 |
fs.readdir(path.resolve(dir, "node_modules"), function (er, c) { |
296 | 304 |
children = c || [] // error is ok, just means no children. |
305 |
children = children.filter(function (p) { |
|
306 |
return !p.match(/^[\._-]/) |
|
307 |
}) |
|
297 | 308 |
next() |
298 | 309 |
}) |
299 | 310 |
|
Also available in: Unified diff