walk through file system and output a tree
npm install treee
- dirpath {Stirng}: the dir you want to get file system tree from
- options {Object}: options including:
nodeName
{String}, default:name
: the key you want to get file node name fromskipDotDir
{Boolean}, default:false : ignore dot prefix dir or not (e.g,.gitignore
)showEmptyChildren
{Boolean}, default:false : show empty children array even if the node doesn't contain any childrenshowRelative
{Boolean}, default:false : add apath
attribute to every node, showing the relative path from thedirpath
absolutePath
{Boolean}, default:false : show absolute path in every node
var treee= require('treee');
treee.get(<dirpath>, { nodeName: 'label' })
.then(function(tree){
// do whatever you want to the tree
/* tree=
{
label: "folder",
type: "dir",
children: [
{
label: "test1",
type: "file"
},
{
label: "test2",
type: "file",
}
]
}
*/
})