1 module.exports = installedDeep
3 var npm = require("../../npm.js")
4 , readInstalled = require("read-installed")
6 function installedDeep (opts, cb) {
9 , depth = npm.config.get("depth")
10 , opt = { depth: depth, dev: true }
12 if (npm.config.get("global")) local = [], next()
13 else readInstalled(npm.prefix, opt, function (er, data) {
14 local = getNames(data || {})
18 readInstalled(npm.config.get("prefix"), opt, function (er, data) {
19 global = getNames(data || {})
23 function getNames_ (d, n) {
24 if (d.realName && n) {
25 if (n[d.realName]) return n
29 Object.keys(d.dependencies || {}).forEach(function (dep) {
30 getNames_(d.dependencies[dep], n)
34 function getNames (d) {
35 return Object.keys(getNames_(d))
39 if (!local || !global) return
40 if (!npm.config.get("global")) {
41 global = global.map(function (g) {
45 var names = local.concat(global)
46 return cb(null, names)