-
Notifications
You must be signed in to change notification settings - Fork 10
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
loading all files with certain name #1
Comments
@brentonhouse you are right. Thanks for your feedback and also sorry for inconvenience! The problem comes from the fact that the way |
@brentonhouse const path = require('path')
const klawSync = require('klaw-sync')
const filterFn = item => path.basename(item.path) === 'package.json'
const paths = klawSync('/some/dir', { filter: filterFn }) |
I have a question about this change. I was using ignore, but since this change I'm now using a filter in 2.0.0. I have the following code const files = walk(directory, {
nodir: true,
filter: filterFn,
noRecurseOnFailedFilter: true
}); My filter function excludes items properly, but it seems that it doesn't respect the "nodir" option; it is including directories too in the "files" return when all I want is files. Is this expected behavior? How would I get rid of the directories in this call when using a filter function? |
@jmquigley thanks for your feedback. It is not an expected behavior. |
@jmquigley |
It doesn't work as I would have expected (when using a filter function). If I have the following example structure:
And I walked the directory at
If I leave off the
But that is not what I get back. What I get back now is an empty array. What is happening is that once a directory is suppressed with the nodir option, then all subdirectories appear to be gone along with the files. The whole example structure above is gone, when I would have expected to still get the file. When I do this without the filter function it works as expected, but then I lose the custom filtering. Hope this helps. |
It is a little hard to tell without knowing your |
Here is the code: const filterFn = (item: any) => {
return self.ignore.every((it: string) => {
return (item.path.indexOf(it) > -1) ? false : true;
});
};
const files = walk(directory, {
nodir: true,
filter: filterFn,
noRecurseOnFailedFilter: true
}); The |
@jmquigley please try without |
@jmquigley ping?! |
@jmquigley did that solve your issue? |
Sorry, I haven't had the chance yet to test it again. I will do so in the next hour and get back to you. |
Yes, that works as long as the option "noRecurseOnFailedFilter" is excluded from the options when using "nodir: true". |
Great! I am happy that resolved your issue 😄 About |
Closes via 68d40ec. |
After switching to klaw, I seem to be having some issue loading only files with a certain name.
Say I want to recursively load only files named
package.json
. It seems like I could do something like:I have also tried several other variations of the ignore pattern but nothing seems to match properly.
I am probably missing something obvious... Any ideas?
The text was updated successfully, but these errors were encountered: