-
Notifications
You must be signed in to change notification settings - Fork 12
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
Can't use includeFilter on folders #67
Comments
Let's say we stick to your proposal and use I agree it is a little bit tricky, but if you have a certain usecase we could investigate more. Also don't forget that currently it is possible to use the 'includeFilter' on directories using glob patterns.
|
Thanks for your reply. Here is my usecase : I want to compare two folders content on specific subfolders & files only. Example : Left structure Right structure Filter : Expected Result : Actual Result : I have made many tests. I also tested the 'negate' option from minimatch on the excludeFilter. From your point of view, what would be the best way to restrict comparison of two folders on specific files & subfolders ? |
Yes, this could be improved. I will think about it. Meanwhile you can use the Custom result builder and implement your own logic. I am using two options. includeFilter: '**/folderA1/**,**/folderA2/**,/file1', // this already exists and filters files
includeFolders: '**/folderA1, **/folderA2', // this new one is used to filter folders
You can run the example like this: unzip test.zip
npm install
node test.js Note that the end statistics are no longer to be trusted since we are altering he result after the statistics are created. If you need all of them, you would have to create your own stats based on Result.diffSet. Hope it helps. |
Thank you very much, @gliviu ! Before opening this ticket, I read the documentation and though the Custom Result Builder could be an option but wasn't really confident on how. Your example was perfect. I made some modifications and it worked perfectly for what I intended to do. My dir-compare Options: My Custom Builder : if (options.noDiffSet) { diffSet.push({ It's all OK for me. |
Decided to leave includeFilter and excludeFilter logic unchanged, just to preserve backwards compatibility. |
When using the "includeFilter" option, it's impossible to filter folders.
Checking the code (
dir-compare/src/Entry/EntryBuilder.ts
Line 110 in 484b59b
Could it be possible to replace the line
if ((entry.stat.isFile() && options.includeFilter) && (!match(path, options.includeFilter))) {
by
if (options.includeFilter && !match(path, options.includeFilter)) {
It then will match what is done for the excludeFilter.
What do you think about it ?
Thanks in advance.
The text was updated successfully, but these errors were encountered: