Skip to content

Updated fork of hughsk/file-tree: Generate a tree of file metadata that matches d3's hierarchy layout format

License

Notifications You must be signed in to change notification settings

citation-js/hughsk-file-tree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fork of https://github.com/hughsk/file-tree

file-tree

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

Installation

npm install file-tree

Usage

require('file-tree')(files, mapper, callback)

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(filename, next) {
  fs.stat(filename, function(err, stats) {
    if (err) return next(err)
    next(null, {
      size: stats.size
    })
  })
}, function(err, fileTree) {
  console.log(fileTree) // done!
})

About

Updated fork of hughsk/file-tree: Generate a tree of file metadata that matches d3's hierarchy layout format

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%