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 ex
I have looked at the above answers and have mixed together this version which works for me:
function getFilesFromPath(path, extension) {
let files = fs.readdirSync( path );
return files.filter( file => file.match(new RegExp(`.*\.(${extension})`, 'ig')));
}
console.log(getFilesFromPath("./testdata", ".txt"));
This test will return an array of filenames from the files found in the folder at the path ./testdata. Working on node version 8.11.3.