4.0.0 • Published 6 years ago

dir-tree-creator v4.0.0

Weekly downloads
74
License
MIT
Repository
github
Last release
6 years ago

dir-tree-creator

npm Build Status

dir-tree-creator is a Node.js module that creates an npm like directory tree structure of the given root path and returns the string representation of it.

Install

npm i dir-tree-creator

Usage

dirtree(dir, opts, cb)

  • dir <String> root directory path
  • opts <Object> (optional) object with the following properties:
    • label <String> label for the root node of the directory tree; if nothing specified, the root path's basename will be used.
    • hidden <Boolean> determines if hidden files should be included; set to false to ignore hidden files; defaults to true.
  • cb <Function>
    • err <Error | null>
    • dirtree <String> string representation of the directory structure

Example

const dirTree = require('dir-tree-creator')

dirTree('some/dir', (err, tr) => {
  if (err) return console.error(err)
  console.log(tr)
})
const dirTree = require('dir-tree-creator')

dirTree('some/dir', { label: 'custom label' }, (err, tr) => {
  if (err) return console.error(err)
  console.log(tr)
})

Sample output

custom label
├─┬ dir0
│ └── file0.js  
├─┬ dir1
│ ├─┬ dir2  
│ │ └── file2.js  
│ └── file1.md
├── file-under-root.js
└── .gitignore  
4.0.0

6 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.4

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago