An open API service indexing awesome lists of open source software.

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.

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)!