https://github.com/zoubin/tree-directory
Print a directory structure in the tree format
https://github.com/zoubin/tree-directory
Last synced: 10 months ago
JSON representation
Print a directory structure in the tree format
- Host: GitHub
- URL: https://github.com/zoubin/tree-directory
- Owner: zoubin
- License: mit
- Created: 2015-10-07T15:31:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-11T03:30:43.000Z (about 10 years ago)
- Last Synced: 2024-12-17T03:42:40.385Z (over 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 13
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tree-directory
[](https://www.npmjs.org/package/tree-directory)
[](https://travis-ci.org/zoubin/tree-directory)
[](https://david-dm.org/zoubin/tree-directory)
[](https://david-dm.org/zoubin/tree-directory#info=devDependencies)
Print a directory structure in the tree format
## Example
**Directory structure**
```
example/src
├── page
│ ├── hello
│ │ └── index.css
│ └── world
│ ├── index.css
│ └── index.js
└── vendor
└── index.js
```
To print all javascript files:
```javascript
var tree = require('tree-directory')
tree(__dirname + '/src', '**/*.js').then(function (res) {
console.log(res)
})
```
**Output**
```
├─ page
│ └─ world
│ └─ index.js
└─ vendor
└─ index.js
```
## tree(root[, patterns])
Return a promise which resolves to a treeish string
representing the directory `root` (not including itself).
**root**
The target directory to format.
Type: `String`
**patterns**
[Globs](https://github.com/sindresorhus/globby#patterns)
to match the files to include.
Type: `String`, `Array`
Default: `**/*`
## tree.sync(root[, patterns])
Just return the treeish string.