Creates a plain text scheme or a JS object representing the directory tree. This package is an improvement of directory-tree by @mihneadb.
$ npm install directory-tree-scheme
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]
}
]
}
Full documentation can be found here