Skip to content
This repository has been archived by the owner on Oct 23, 2018. It is now read-only.

Generate a json representation of a file tree with file information

Notifications You must be signed in to change notification settings

trodrigues/node-content-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Generate a json representation of a file tree with file information

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published