Package Exports
- traverse-fs
- traverse-fs/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (traverse-fs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
traverse-fs
Nodejs npm module to traverse files and folder using code, or cli, or use glob patterns
npm i traverse-fs --save
npm i fssys --save
Usage
The API of traverse-fs can be used to traverse a folder or its subfolders recursively.
Simple - Usage
You can use traverse.dir
which by default traverses a single specified folder. However, you can change it to traverse recursively for it sub folders as well. You can find a simple usage of the api as below:
var traverse = require("traverse-fs);
var path = require("path");
traverse.dir("./").then(console.log);
// Alternatively, you can specify specific callbacks of your own and go recursive traversing
traverse.dir("./", true, (dir, file) => { return path.join(dir, file.name) }).then(console.log);
Simple - Return Nested Array
You can use the directory/ folder traversing and get a return of a nested array (array of arrays) as the result.
var traverse = require("traverse-fs);
var path = require("path");
traverse.dir("./", false, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "nestedarray").then(console.log);
// Alternatively, you can specify specific callbacks of your own and go recursive traversing
traverse.dir("./", true, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "nestedarray").then(console.log);
Simple - Return Single Level Array
You can use the directory/ folder traversing and get a return of a single level array as the result. The result will have the complete path of the file in case the file being in the sub directory.
var traverse = require("traverse-fs);
var path = require("path");
traverse.dir("./", false, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "flatarray").then(console.log);
// Alternatively, you can specify specific callbacks of your own and go recursive traversing
traverse.dir("./", true, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "flatarray").then(console.log);
Simple - Return JSON
var traverse = require("traverse-fs);
var path = require("path");
traverse.dir("./", false, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "json").then(console.log);
// Alternatively, you can specify specific callbacks of your own and go recursive traversing
traverse.dir("./", true, (dir, file) => { return path.join(dir, file.name) }, true, (error) => { console.log(error); }, "json").then(console.log);
Simple - Simple Search usage
TODO
Simple - Simple Search usage with Return Nested Array
TODO
Simple - Simple Search usage with Return Single Level Array
TODO
Simple - Simple Search usage with Return JSON
TODO
CLI - Simple CLI Get usage
TODO
CLI - Simple CLI Search usage
TODO
API for traverse-fs / fssys
traverse.dir
traverse.returns
traverse.returnNestedArray
traverse.returnFlatArray
traverse.returnJSON
traverse.callbacks
traverse.callbacks.defaultFetch
traverse.callbacks.jsonFetch
traverse.callbacks.errorHandler
traverse.search
traverse.regex
traverse.cliargs
Contribution
Please feel to make contributions or raise issues to the repository by creating a pull request or raising an issue