
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
tree-node-cli
Advanced tools
Lists the contents of directories in a tree-like format, similar to the Linux tree command.
Lists the contents of directories in a tree-like format, similar to the Linux tree
command. Both CLI and Node APIs are provided.
Tree is a recursive directory listing program that produces a depth indented listing of files. When a directory argument is given, tree lists all the files and/or directories found in the given directory.
Note: Symlinks are not followed.
$ npm install tree-node-cli
# or globally
$ npm install -g tree-node-cli
$ tree -L 2 -I "node_modules"
tree-node-cli
āāā LICENSE
āāā README.md
āāā __tests__
ā āāā __fixtures__
ā āāā __snapshots__
ā āāā fixtures
ā āāā tree.test.js
āāā bin
ā āāā tree
āāā jest.config.js
āāā package.json
āāā tree.js
āāā yarn.lock
$ tree [options] [path/to/dir]
Note: Use the command treee
on Windows and Linux to avoid conflicts with built-in tree
command.
The following options are available:
$ tree -h
Usage: tree [options]
Options:
-V, --version output the version number
-a, --all-files All files, include hidden files, are printed.
--dirs-first List directories before files.
-d, --dirs-only List directories only.
-s, --sizes Show filesizes.
-I, --exclude [patterns] Exclude files that match the pattern. | separates alternate patterns. Wrap your entire pattern in double quotes. E.g. `"node_modules|coverage".
-L, --max-depth <n> Max display depth of the directory tree.
-r, --reverse Sort the output in reverse alphabetic order.
-F, --trailing-slash Append a '/' for directories.
-S, --line-ascii Turn on ASCII line graphics.
-h, --help output usage information
const tree = require('tree-node-cli');
const string = tree('path/to/dir', options);
options
is a configuration object with the following fields:
Field | Default | Type | Description |
---|---|---|---|
allFiles | false | Boolean | All files are printed. By default, tree does not print hidden files (those beginning with a dot). |
dirsFirst | false | Boolean | List directories before files. |
dirsOnly | false | Boolean | List directories only. |
sizes | false | Boolean | Show filesizes as well. |
exclude | [] | Array | An array of regex to test each filename against. Matching files will be excluded and matching directories will not be traversed into. |
maxDepth | Number.POSITIVE_INFINITY | Number | Max display depth of the directory tree. |
reverse | false | Boolean | Sort the output in reverse alphabetic order. |
trailingSlash | false | Boolean | Appends a trailing slash behind directories. |
lineAscii | false | Boolean | Turn on ASCII line graphics. |
const string = tree('path/to/dir', {
allFiles: true,
exclude: [/node_modules/, /lcov/],
maxDepth: 4,
});
console.log(string);
MIT
FAQs
Lists the contents of directories in a tree-like format, similar to the Linux tree command.
The npm package tree-node-cli receives a total of 41,969 weekly downloads. As such, tree-node-cli popularity was classified as popular.
We found that tree-node-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.