need a code snippet to find all *.html under a folder in nodejs

Posted by Nicolas S.Xu on Stack Overflow See other posts from Stack Overflow or by Nicolas S.Xu
Published on 2014-08-23T09:38:56Z Indexed on 2014/08/23 10:21 UTC
Read the original article Hit count: 164

Filed under:

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.

© Stack Overflow or respective owner

Related posts about node.js