-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Feature request: negative patterns removing parent paths too #15
Comments
I believe that's the expected globbing behavior: Adding your suggested magic does not only add complexity, it may also yield unexpected results for usages other than deleting. I believe the correct solution would be changing your glob patterns to: ['parent/**', '!parent/level1', '!parent/level1/level2', '!parent/level1/level2/test.txt'] @sindresorhus WDYT? |
Of course I don't want the default behaviour to change. I would suggest adding an option preferably in the options object, like the 'nodir' option for node-glob. For simple situations your suggested solution would of course work, but in more complex situations it might get impractical or even impossible. Think of patterns where you want to keep the intermediate parent directories dynamic / you just don't know them. F.e. if you have some wildcards inside the negative match (see also sindresorhus/del#3 (comment)). How would you handle this currently? |
I see.
If you want the exactly same behavior as node-glob, then you can pass If you want negative globs to also "match" the directories which are ancestors of a match (thus removing them from the results set), then things are more tricky. Perhaps a config option would make sense. |
I think this will have to be resolved in |
If you have a match like
['parent/**','!/parent/level1/level2/test.txt']
currently the parent directories of test.txt will remain in the matching list:
If you want to use f.e. https://github.com/sindresorhus/del to delete these matches test.txt will be removed too. To delete a directory, but preserve some subset, the parent directories of any negative match need to be removed too.
See also sindresorhus/del#3
The text was updated successfully, but these errors were encountered: