Closed TwitchBronBron closed 2 years ago
Try this:
const fs = require("fs");
const { fdir } = require("./index");
//make some temp files to scan
if (!fs.existsSync("./temp")) {
fs.mkdirSync("./temp");
fs.writeFileSync("./temp/alpha.json", "");
fs.writeFileSync("./temp/beta.txt", "");
}
//find only the files that match the glob
const results = new fdir()
.glob("*.txt")
.crawl("./temp")
.sync();
console.log(results);
You can either use the builder pattern or crawlWithOptions
— not both. That was the only issue with this.
That did the trick, thanks!
What is the correct way to utilize the globbing functionality in fdir? When I run the following test, it does not properly filter the results.
The glob seems to have no effect, and I'm instead given all of the files in the directory.
Am I using it wrong? I've installed picomatch, and tried this on fdir 5.2.0, 5.1.0, 5.0.0, 4.1.0, and 4.0.0, all with the same results.
Running the same test but fast-glob (which also uses picomatch) returns the expected results.