1.0.3 • Published 5 years ago
treek v1.0.3
treek
Convert the specified directory tree to a JS object
Install
yarn add treek
Usage
const treek = require('treek')
console.log(treek('/your/directory'))
Option
Use regular expressions to ignore
some folders or file names
treek('/your/directory', {
ignore: /node_modules/
})
Use ext
to get only the file containing the extension
treek('/your/directory', {
ext: ['.js', '.ts']
})
Result
[
{
name: 'package.json',
path: '/User/root/Desktop/treek/package.json',
type: 'file',
size: 305,
extension: '.json',
children: []
}, {
name: 'src',
path: '/User/root/Desktop/treek/src',
type: 'directory',
size: 888,
extension: null,
children: [
{
name: 'index.js',
path: '/User/root/Desktop/treek/src/index.js',
type: 'file',
size: 342,
extension: '.js',
children: []
}
// ...
]
}
]