You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
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:
varfilterArray=['CVS','*.idea','*.DS_Store'];filterArray.forEach(function(value,index,array){// file extensionif(value.match(/^\*\./))// /^\*/ searches for '*.' (\*) in the beginning (^)value=value.replace(/^\*/m,'');// removes leading '*' for file extensionelsevalue='^'+value;// add leading ^for directories and filesvalue+='$';// append $ for file extensions, files and directoriesarray[index]=value;});varfilterRegExp=newRegExp(config.filter.join('|'));wrench.copyDirSyncRecursive(inputPath,outputPath,{filter: filterRegExp});
You could inline the helper function so opts.filter can be a RegExp or an Array.
What do you think?
The text was updated successfully, but these errors were encountered:
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).
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?
The text was updated successfully, but these errors were encountered: