directory-tree-scheme
v1.0.3
Published
Creates a plain text scheme or a JS object representing the directory tree.
Downloads
2
Readme
directory-tree-scheme
Creates a plain text scheme or a JS object representing the directory tree. This package is an improvement of directory-tree by @mihneadb.
Install
$ npm install directory-tree-scheme
Usage
For example, we have a directory called photos that looks like this:
import { build_scheme } from "directory-tree-scheme";
const tree = build_scheme("/path-to/photos-directory");
console.log(tree);
Running the code above will console log the following plain text tree:
├── notes.txt
├── summer
│ └── june
│ └── windsurf.txt
└── winter
├── december
│ ├── christmas.txt
│ ├── fun.txt
│ └── new_year.txt
└── january
├── ski.txt
└── snowboard.txt
You can also get the tree as a JS object:
import { build_tree } from "directory-tree-scheme";
const tree = build_tree("/path-to/photos-directory");
console.log(tree);
Running the code above will console log the following plain text tree:
{
path: '/photos',
name: 'photos',
children: [
{
path: '/photos/notes.txt',
name: 'notes.txt'
},
{
path: '/photos/summer',
name: 'summer',
children: [Array]
},
{
path: '/photos/winter',
name: 'winter',
children: [Array]
}
]
}
Other
Full documentation can be found here