-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not filter each file, stops on first false #187
Comments
Thanks for reporting. Do you have any code (along with a description of the file tree) so that I can reproduce this bug? |
I don't have the code anymore, since I changed the approach to not need to use the filter. But I'll try to reproduce it again later. thnaks. |
I am having this problem also. (I ended up writing my own copy folder function using your walk function and copy function that takes two paths and a filter, which worked well.) Here's what I did when using your copy function to copy a folder with a filter: fs.copy('/home/myuser/projects/website', '/home/myuser/public_html/customfolder', { 'clobber': true,
'preserveTimestamps': true, filter: /\.php$/i },
function (err) {
if (err) return console.error('Error copying ' + item.path + ': ' + err);
console.log('Copied file ' + item.path);
}) It seems like it applies the filter to the source path, when I look at the code, and doesn't get to the point where it enumerates the files and folders recursively to filter them. Maybe I'm reading it incorrectly. This is what I see in your code: ncp.js: ...
function ncp (source, dest, options, callback) {
...
var currentPath = path.resolve(basePath, source)
...
startCopy(currentPath)
function startCopy (source) {
started++
if (filter) {
if (filter instanceof RegExp) {
if (!filter.test(source)) {
return doneOne(true) but I don't see it looping or any recursion prior to the filter check. That doesn't happen until onDir which is down the call stack from startCopy. It just tests the source path, which would be the root source directory. It seems like the check should be done instead in the copyFile function or onFile function to test each file individually instead. |
When walk on files,the regExp's lastIndex will increase. Right code must be: |
Regular expression filters aren't supported anymore, closing as a wontfix. |
I've got same issue as #70 .
Im using latest release.
"fs-extra": "^0.26.0",
The text was updated successfully, but these errors were encountered: