content-tree

0.0.1 • Public • Published

node-content-tree

Generate a json representation of a file tree with file information

Installation

npm install content-tree

Usage

var tree = require('content-tree')('/path/to/directory');
tree.generate(function(tree){
  console.log(tree);
});

Or if you want a promise based interface

var tree = require('content-tree')('/path/to/directory');
tree.generate().then(function(tree){
  console.log(tree);
});

Then it's probably useful to use something like traverse.

File object information

Each file object will have not only the file path but the stat file object as well as mime type and charset information:

{
  path: 'file path',
  basename: 'file basename',
  stat: [Stat object],
  mimeType: 'file mimetype',
  charset: 'file charset'
}

If you wish to enhance the information for each object, you can use the file event as such:

var somePath = '/path/to/directory';
var tree = require('content-tree')(somePath);
tree.on('file', function(file){
  file.relativePath = file.path.replace(somePath +'/', '');
})
tree.generate();
 

API

TODO: finish this section

generate

getRelativePath

getRelativeFilePath

Events

file

TODO

  • finish documentation
  • tests

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    2

Package Sidebar

Install

npm i content-tree

Weekly Downloads

2

Version

0.0.1

License

MIT

Last publish

Collaborators

  • trodrigues