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

directory-tree

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-tree

Convert a directory tree to a JS object.

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104K
decreased by-19.17%
Maintainers
1
Weekly downloads
 
Created

What is directory-tree?

The directory-tree npm package is a utility for generating a nested directory structure in JSON format. It is useful for visualizing and working with file system hierarchies in a programmatic way.

What are directory-tree's main functionalities?

Generate Directory Tree

This feature allows you to generate a JSON representation of a directory structure starting from a specified path. The code sample demonstrates how to use the package to create a directory tree and print it in a readable JSON format.

const dirTree = require('directory-tree');
const tree = dirTree('/some/path');
console.log(JSON.stringify(tree, null, 2));

Filter by File Extensions

This feature allows you to filter the files included in the directory tree by their extensions. The code sample shows how to generate a directory tree that only includes Markdown and JavaScript files.

const dirTree = require('directory-tree');
const tree = dirTree('/some/path', { extensions: /\.(md|js)$/ });
console.log(JSON.stringify(tree, null, 2));

Exclude Specific Paths

This feature allows you to exclude specific paths from the directory tree. The code sample demonstrates how to exclude the 'node_modules' directory from the generated tree.

const dirTree = require('directory-tree');
const tree = dirTree('/some/path', { exclude: /node_modules/ });
console.log(JSON.stringify(tree, null, 2));

Other packages similar to directory-tree

Keywords

FAQs

Package last updated on 30 Apr 2019

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