file-tree

Generate a tree of file metadata that matches d3's hierarchy layout format

file-tree

A more flexible, asynchronous version of file-size-tree.

npm install file-tree

Takes an array of files.

mapper(filename, next) should pass an object to the the callback with the metadata you want to associate with the file.

callback(err, tree) is called when everything's done.

var tree = require('file-tree')
var fs = require('fs')
 
tree([
    __dirname + '/project/src/index.js'
  , __dirname + '/project/src/README.md'
  , __dirname + '/project/src/package.json'
  , __dirname + '/LICENSE'
], function(filenamenext) {
  fs.stat(filename, function(errstats) {
    if (err) return next(err)
    next(null, {
      size: stats.size
    })
  })
}, function(errfileTree) {
  console.log(fileTree) // done! 
})