Parses a directory into a nicely-formatted ASCII tree. Includes a CLI.
npm install @karmaniverous/dirtreebash
npm install @karmaniverous/dirtree
`
To import:
`js
import { dirtree } from '@karmaniverous/dirtree;
An Example
`text
PS C:\> dirtree -d src -a size
└─ src
├─ cli
│ └─ index.mjs: 1344
└─ export
├─ dirtree
│ ├─ dirtree.mjs: 2045
│ └─ dirtree.test.mjs: 303
└─ index.mjs: 73
`
Command Line Interface
`text
Usage: dirtree [options]
Options:
-a, --attribute Decorate files with an fs.Stats attribute. https://nodejs.dev/en/api/v19/fs/#fsstats
-n, --depth Limit the tree to this depth. Default is unlimited.
-d, --dir Path to starting directory. Defaults to current working directory.
-e, --exclude RegExp pattern to exclude paths from tree.
-h, --help display help for command
``
stringKind: global function
Returns: string - ASCII tree.
| Param | Type | Description |
| --- | --- | --- |
| [options] | Object | Options object. |
| [options.attribute] | string | Decorate files with an fs.Stats attribute. https://nodejs.dev/en/api/v19/fs/#fsstats |
| [options.debug] | boolean | Log intermediate steps to console. |
| [options.depth] | number | Limit the tree to this depth. Default is unlimited. |
| [options.dir] | string | Path to starting directory. Defaults to current working directory. |
| [options.exclude] | RegExp | RegExp pattern to exclude paths from tree. |
---
See more great templates and other tools on
my GitHub Profile!