Allow * and ? to be used in file system operations to match any number of characters or a single character in a file or folder path.
Abstract the logic to build a regex string based on the wildcard into a library. Create a method that accepts:
The file pattern
A closure to be executed for each match
The method will loop over everything in that directory and run the closure against every match. Something like this:
edit: Look at the Globbing patterns of Grunt for some other approaches. Note, Grunt matches file paths outside the task and simply passes an array of the matched paths in.
Globbing solution used was a variation of the file globber already built for the box.json ignores syntax which is similar to npm's standard file globbing.
Use * to match any directory or file name
Use ** to match recursively across directories
use ? to match a single character
Globber supports a fluent API that allows you to get an array of matching file paths back or to execute a closure against each.
Returns an array of all text files recursively below the myFolder directory whose name end with bar.
Apply a closure to all markdown files in a directory.
These commands updated to allow for file globbing: