Get directory structur
$ npm install -g directory-structur
On terminal, type
-
$ dir-tree
or $ directory-structur
Property | Type | Description |
---|---|---|
ignore | Array or string | Ignore it when find |
maxDept | number | Limit max dept on directory |
`json | tree` | |
path | string | Only support on cli |
$ dir-tree maxDept=10
$ dir-tree ignore=[\"node-modules\",\"json\"]
$ dir-tree print=json
$ dir-tree path=../
$ npm install directory-structur
or $ yarn add directory-structur
const dir = require('directory-structur'); // or
// import dir from 'directory-structur';
const options = {
ignore: ['node-modules'],
//... other options
};
const res = dir('./', options);
console.log(res);
My Directory
├--.editorconfig
├--.gitignore
├--.npmignore
├--.prettierrc.js
├--.vscode
| ├--extensions.json
| ├--settings.json
├--README.md
├--cli.js
├--func.js
├--index.js
├--node_modules
| ├--.yarn-integrity
| ├--node-argv-to-object
| | ├--README.md
| | ├--index.js
| | ├--package.json
| | ├--sample.js
├--package.json
├--yarn.lock
{
path: './',
name: 'My Directory',
depth: 0,
parent: 1,
type: 'directory',
children: [{
path: '.editorconfig',
name: '.editorconfig',
depth: 0,
parent: 0,
type: 'file',
extension: '.editorconfig'
},
{
path: '.gitignore',
name: '.gitignore',
depth: 0,
parent: 0,
type: 'file',
extension: '.gitignore'
},
{
path: '.npmignore',
name: '.npmignore',
depth: 0,
parent: 0,
type: 'file',
extension: '.npmignore'
},
{
path: '.prettierrc.js',
name: '.prettierrc.js',
depth: 0,
parent: 0,
type: 'file',
extension: '.js'
},
{
path: '.vscode',
name: '.vscode',
depth: 0,
parent: 0,
type: 'directory',
children: [Array]
},
{
path: 'README.md',
name: 'README.md',
depth: 0,
parent: 0,
type: 'file',
extension: '.md'
},
{
path: 'cli.js',
name: 'cli.js',
depth: 0,
parent: 0,
type: 'file',
extension: '.js'
},
{
path: 'func.js',
name: 'func.js',
depth: 0,
parent: 0,
type: 'file',
extension: '.js'
},
{
path: 'index.js',
name: 'index.js',
depth: 0,
parent: 0,
type: 'file',
extension: '.js'
},
{
path: 'node_modules',
name: 'node_modules',
depth: 0,
parent: 0,
type: 'directory',
children: [Array]
},
{
path: 'package.json',
name: 'package.json',
depth: 0,
parent: 0,
type: 'file',
extension: '.json'
},
{
path: 'yarn.lock',
name: 'yarn.lock',
depth: 0,
parent: 0,
type: 'file',
extension: '.lock'
}
]
}