-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
New: Added ignore option (fixes #115) #151
Conversation
Odd how the only failing test is due to 2 paths out of order in Node 0.11 only. Nice work, I'll start experimenting with this tomorrow hopefully. //cc @contra @sindresorhus |
31797f5
to
0ece278
Compare
@UltCombo had those failed cases randomly thrown on my local as well but they may be due to race conditions mentioned in the README?. Travis is clear now. |
@UltCombo did u get a chance to test it? |
Sorry, hadn't had time to test it throughout. I just pushed a new branch to globby using node-glob's Ignoring some files in a directory through the Ignoring a whole dir ( |
@UltCombo thanks for taking the time to benchmark it 👍 So I put $100 on bountysource for this but it was on the other issue #, not sure how to move it over here but I'll contact them about that. |
13bf508
to
9f2958a
Compare
@UltCombo Thanks for the benchmarks.
Creating only one instance now.
Using setImmediate to return the callback has fixed the issue. Ref:- logicalparadox/matcha#9 Although there may be minor diffs, but following are the results from the existing globby benchmarks 👍 :
|
Nice! |
Updated benchmarks on fixing globby sync:-
|
Oh, I was about to start working on that, thank you very much! |
Sure. made a quick fix for now. updating it. |
Thanks, no hurry. Sending a quick fix plus the Matcha fix is okay, @sindresorhus and I can clean it up afterwards. |
Have sent fix for sync. Matcha fix? Do you mean the setImmediate fix? It's part of node-glob. |
@@ -74,6 +75,27 @@ function setopts (self, pattern, options) { | |||
self.statCache = options.statCache || Object.create(null) | |||
self.symlinks = options.symlinks || Object.create(null) | |||
|
|||
self.ignore = options.ignore || [] | |||
|
|||
if(!Array.isArray(self.ignore)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add space to match the style in the rest of the file.
Sorry, I was unclear. I'm not saying that the optimization is not a requirement for release of this feature. I'm saying it's premature in advance of correct behavior. The first step should be to implement the contract correctly, and provide a mountain of tests for every conceivable edge case. Then add optimizations, each time also adding more tests to guarantee that the optimization's new edge cases don't break the contracts. I'll review again tomorrow and see if I can poke any new holes in it ;) |
@vegetableman Thanks for your patience on this, btw. I know it's frustrating when you make a contribution and the author puts you through the ringer, but since this module is used by many high-profile fs libs, it's important to be really careful about anything that can introduce surprising edge cases. In the worst case, they end up depending on those bugs, and then when we fix them, it causes problems. |
Thanks @isaacs for your patience as well. You are awesome 👍 . |
81df20e
to
b5ac82c
Compare
Added more tests including tests for negation and brace-expansion to accelerate this PR. |
I don't think "negative ignores" is a good idea. Maybe we should just throw in that case. If you want something to not be ignored, then put it in the pattern. It opens the door for folks to do crazy stuff like Added one minor comment, will review in more detail later. |
b5ac82c
to
bbded51
Compare
Agreed. It's kind of awkward and the current functionality simply reverses an ignore and excludes other non-matching files. May be we could go the globby way of supporting multi-globs. Something like glob(['a/b', 'b/c']) It's worth noting that globby supports an interesting way of handling multi-globs and corresponding ignore list. Refer:- sindresorhus/globby#6. |
node-glob's lack of multi-glob support is the sole reason globby exists. Also worth noting that glob-stream implements the very same logic as globby as well (albeit it consumes node-glob's EventEmitter API instead of the callback/sync ones). Multi-glob support + a streaming API (#70) should make glob-stream obsolete as well. |
multi-glob support and a streaming API would completely solve our issues and perf bottlenecks in gulp and I'm sure in a lot of other projects |
Let's discuss multi-glob and streaming in other issues, plz. |
@vegetableman Getting closer, but logic's still not quite right.
In this case, it should only ignore patterns that would be matched by However, as you can see, it's failing to even explore the child directories in
|
bbded51
to
9c51d61
Compare
Thanks @isaacs for finding the bug. Great catch 👍 . |
e4fcfc0
to
19fa2e9
Compare
@isaacs The star handing logic has been simplified with support only for globstar, that is, ignore traversing if globstar, and minimatch check for the rest. I think this could be merged. |
Ok! Landed this on master. @vegetableman I had a few other suggestions, which were mostly pretty minor, and I went ahead and just made the changes myself. Since we've gone back and forth a bunch on this, and you seemed to be getting something out of the process, I want to share the reasoning behind both:
Will release with a bumped minor later today. Might try to get a few other PRs in there as well. |
Thanks for the refactor @isaacs . Makes sense and is much more comprehensible. |
Oooooooohhhhhhh! Waiting on a PR for glob-stream now to incorporate this. Thanks @isaacs 🎈 |
@contra Have sent a bounty request. Waiting for you to accept it. 💸 |
@vegetableman Sent - thanks! |
fixes #115
In addition to
minimatch
check, the code checks if a particular pattern ends with a glob star**
, if it does, adds the directory to the ignore list and stops traversal for the directory matching the pattern.Also, if, for example,
a/**
is added to the ignore list, it removesa
from the resulting match list.