Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

content-tree

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content-tree

Generate a json representation of a file tree with file information

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 07 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc