# @fremango/dir-tree

> Get a tree view of the directory structure.

Latest version **0.0.2** (published 2019-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fremango/dir-tree
pnpm add @fremango/dir-tree
yarn add @fremango/dir-tree
bun add @fremango/dir-tree
```

Provides the command `dir-tree`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-06-24 |
| First published | 2019-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 247.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fremango |
| Maintainers | fremango |

## Links

- npm: https://www.npmjs.com/package/@fremango/dir-tree
- Repository: https://github.com/itcat99/dir-tree
- Homepage: https://github.com/itcat99/dir-tree#readme
- Issues: https://github.com/itcat99/dir-tree/issues
- npm.io page: https://npm.io/package/@fremango/dir-tree

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [commander](https://npm.io/package/commander.md) ^2.20.0

## Recent versions

- 0.0.2 (latest) — 2019-06-24
- 0.0.1 — 2019-05-25

## README

# dir-tree

Get a tree view of the directory structure.

![screenshot](https://github.com/itcat99/dir-tree/blob/master/assets/screenshot.png)

## Install

```bash
yarn add global @fremango/dir-tree

#or
npm i -g @fremango/dir-tree
```

## Usage

### Cli

```bash
dir-tree <dir> [options]
```

### Nodejs

```js
const { dirTree, scanDir } = require("dir-tree");

const dir = scanDir({
  dir: "./"
});
console.log("dir for Object", JSON.stringfly(dir, null, 2));
const tree = dirTree({
  dir: "./"
});

console.log("Tree: ", tree);
```

## Apis

### scanDir

> Scan the directory with the configured options, return directory struct object

scanDir(Options, callback)

return `dirStruct`

#### dirStruct

| name     | type        | default | desc                                                                  |
| -------- | ----------- | ------- | --------------------------------------------------------------------- |
| name     | string      | ''      | directory name                                                        |
| isDir    | boolean     | false   | is directory                                                          |
| path     | string      | ''      | directory absolute path                                               |
| children | dirStruct[] | []      | if isDir is `true`, `children` is this directory's children directory |

#### callback

> custom the structure of each item

(itemStruct) => itemStruct

| name       | type      | desc                      |
| ---------- | --------- | ------------------------- |
| itemStruct | dirStruct | directory's struct object |

### dirTree

> return a tree view of the directory structure.

dirTree(options)

## Options

### deep

desc: Scan the depth of the directory, if it is 0, scan all directories and their subdirectories

type: number

default: 0

use in cli: `-d <number>` or `--deep <number>`

### ignore

desc: Ignored directory

type: string[]

default: undefined

use in cli: `-i "<dir>,<dir>,..."` or `--ignore "<dir>,<dir>,..."`

### noChild

desc: Don't scan subdirectories of this directory

type: string[]

default: undefined

use in cli: `-n "<dir>,<dir>,..."` or `--noChild "<dir>,<dir>,..."`

### color

desc: Output color text

type: Boolean

default: true

use in cli: `--no-color` disabled color text

---
_Source: https://npm.io/package/@fremango/dir-tree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
