https://github.com/karmaniverous/dirtree
Parses a directory into a nicely-formatted ASCII tree. Includes a CLI.
https://github.com/karmaniverous/dirtree
console directory-tree pretty-print terminal tree treeify
Last synced: 5 months ago
JSON representation
Parses a directory into a nicely-formatted ASCII tree. Includes a CLI.
- Host: GitHub
- URL: https://github.com/karmaniverous/dirtree
- Owner: karmaniverous
- Created: 2022-12-18T09:50:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-12T05:56:43.000Z (almost 2 years ago)
- Last Synced: 2025-10-13T15:35:06.118Z (8 months ago)
- Topics: console, directory-tree, pretty-print, terminal, tree, treeify
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@karmaniverous/dirtree
- Size: 2.51 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# dirtree
Parses a directory into a nicely-formatted ASCII tree. Includes a CLI.
To install:
```bash
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
```
# API Documentation
## dirtree([options]) ⇒ string
Extracts an ascii tree representing the file structure under a directory path.
**Kind**: 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](https://github.com/karmaniverous)!