A library to handle nested directory structures in Node.js using the EventEmitter API and recursion.
npm install tree-trav
Tree API Documentation
const Tree = require('tree-trav').Tree;
let myTree = new Tree();
let stylesheets = [];
let jsFiles = [];
// Find all CSS and JS files in a
// nested file structure
myTree.getLeaves('example/root/', [
'.css',
'.js'
]);
// Deal with files as they are found
myTree.on('file', (file, dir, extension) =>{
if(extension === '.js')
jsFiles.push(file);
if(extension === '.css')
stylesheets.push(file);
});
Contributors Welcome!