traverse-dir
v1.0.0
Published
Traverse a directory recursively, call a callback method for all files and directorys
Downloads
1
Readme
Traverses a directory recursively.
const { traverseDirectory } = require("traverse-directory");
traverseDirectory(".",
(file) => console.log(file.name),
(directory) => {
console.log(directory.name)
return true;
)
);
Calls fileCallback
for each file and directoryCallback
for each directory
The fileCallback
callback function is called for each files. An object is passed as parameters with the following fields:
name
: The filenamerelativeDirectoryPath
: The file's directory relative pathrelativeFilePath
: The file's relative pathfullDirectoryPath
: The file's directory full pathfullFilePath
: The file's full path
The directoryCallback
is optional. It must return true if directory should be parsed. If the directoryCallback
is not provided, all directorys will be parsed. An object is passed as parameter of the callback:
name
: The directory namerelativePath
: The directory's relative pathfullPath
: The directory's full path