GitXplorerGitXplorer
t

node-content-tree

public
1 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
7c68a8a35225cfce1a2de30b174ce317c39277be

remove comment telling me to split this into a module

ttrodrigues committed 12 years ago
Unverified
5f27f7f4ea45b17f302e9518eab46f4d780ce26e

merge readme

ttrodrigues committed 12 years ago
Unverified
5f3ed0b92ca917a7badb1f0e75dceb0d20f50917

add dependencies

ttrodrigues committed 12 years ago
Unverified
51d4d5bd5732f586221219b18f1426cc321235f1

initial commit

ttrodrigues committed 12 years ago
Unverified
5a318454d511cdd98db98fad6c313164380a3d3f

Initial commit

ttrodrigues committed 12 years ago

README

The README file for this repository.

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