npmd-tree
query/traverse the node_modules
tree
example
#show the tree, as json.
npmd-tree
# compile binary deps.
npmd-tree -c 'if ( test -e binding.gyp) then node-gyp rebuild; fi' --quiet
or from javascript
var tree = require('npmd-tree').tree
var spawn = require('child_process)'.spawn
tree(process.cwd(), {post: function (pkg, cb) {
if(!pkg.gypfile) return cb(null, pkg)
var cp = spawn('node-gyp', ['rebuild'], {cwd: pkg.path})
cp.stdout.pipe(process.stdout)
cp.stderr.pipe(process.stderr)
cp.on('exit', next)
cp.on('error', next)
var ended = false
function next (err) {
if(ended) return
ended = true
cb(err)
}
}, function (err, tree) {
if(err) throw err
console.log(tree)
})
License
MIT