1.0.0 • Published 3 years ago

file-tree-maker v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

file-tree-maker

npm module

Introduction

Make the file tree recursively.

Internal implemention used bfs (breadth first search).

Usage

In Node environment.

npm i file-tree-maker

const makeTree = require('file-tree-maker')

makeTree(options) // => pass the `configuration`, and return the `result`, see next.

Configuration

entry - string

Path of the file or the directory, absolute path is recommended.

e.g. - absolute/path/my/dir

exclude - Array<RegExp>

The fullpath of the object matched one of the supplied regular expressions will be skipped.

And do no effect to entry option.

e.g. - [/node_modules/, /\.ingore/]

Result Structure

{
    type: 'file | dir' // => file or directory
    name: 'my_dir_name', // => file or directory name
    fullpath: 'absolute/path/my/dir', // => fullpath
    children: [], // => exists if type is `dir`, children's structure is same as parent's.
}

Tests

yarn test