need a code snippet to find all *.html under a folder in nodejs
- by Nicolas S.Xu
I'd like to find all *.html files in src folder and all its sub folders using nodejs. What is the best way to do it?
var folder = '/project1/src';
var extension = 'html';
var cb = function(err, results) {
// results is an array of the files with path relative to the folder
console.log(results);
}
// This function is what I am looking for. It has to recursively traverse all sub folders.
findFiles(folder, extension, cb);
I think a lot developers should have great and tested solution and it is better to use it than writing one myself.