dir-ls
Do the traversal of the source directory structure
Installation
$ npm install dir-ls --save
Usage
with options mode:
let ls =
without options mode:
let ls =
Docs
There is only one function in dir-ls
.
Function(path[, options])
@param
- path <string>
Do the traversal of the source directory structure, the
pathis the target directory that you want to traverse it.
- options <object>|<Function>
The
optionscould be an object which configures the methods detailedly.
options.readMode {string}
If no readMode is specified, then the raw buffer is returned.
options.justFindWithName {RegExp|string}
This options will filter file name and return the files that you want.
options.justFind {RegExp|string}
This options will filter other file formats and return the files that you want. Notic: if you want to match more than one file format such as json
and js
, you need to write the RegExp like /json$|js$/
to make sure the dir-ls
use the whole word to match the file
options.dirCallback {function}
This function will be called after an directory have been traversed.
options.fileCallback {function}
This function will be called after a file have been traversed.
options.allDone {function}
This function will be called after the whole directory have been traversed.
options.errorHandle {function}
This function will be called when any error were thrown.
object: function
The options
could be a function which perform as options.fileCallback
.
Test
$ npm test