Closed donaldpipowitch closed 12 years ago
I have something similar on this Gist, check copyFilesToDeploy()
and filterFiles()
. Not sure if that is outside the scope of wrench (since the project description only says that it's about recursive file operations).
If people find it useful I'm not against having it as an option. Feel free to make a pull request. ;)
Hi Ryan!
First: Thank you for wrench.
I just wanted to ask if you could enhance the copyDirSyncRecursive function with optional filtering? Currently I hacked something together which looks like this:
Before "var currFile = fs.lstatSync(sourceDir + "/" + files[i]);" in copyDirSyncRecursive I placed the line:
opts.filter holds a RegExp which could look like this: /^CVS$|.idea$|.DS_Store$/
That's all! Just one line and a new property in the opts object.
I use a helper function to create my RegExp before I pass the RegExp into the opts object. My helper function looks basically like this:
You could inline the helper function so opts.filter can be a RegExp or an Array.
What do you think?