Fix --ignore flag when globs are expanded to an array#601
Fix --ignore flag when globs are expanded to an array#601evocateur merged 3 commits intolerna:masterfrom
Conversation
|
At a high-level, it seems somewhat weird to me that That said, the existing logic was clearly designed to handle arrays (it just so happens it didn't quite handle arrays correctly in the negation case and there were no tests for the array case) so I figured fixing this bug in this way seemed appropriate. |
|
Thanks for the patch @rtsao!
That is weird. Is the shell expanding it? Are you in a directory where
Nice catch! Thanks for adding a test for it, too. 🎉 |
| const boolReducer = negate ? Array.prototype.every : Array.prototype.some; | ||
|
|
||
| return glob.some((glob) => maybeNegate(minimatch(pkg.name, glob))); | ||
| return boolReducer.call(glob, (glob) => maybeNegate(minimatch(pkg.name, glob))); |
There was a problem hiding this comment.
Hmmm... this is getting a little roundabout. Maybe simpler at this point to just have a top-level if/else?
Like:
if (negate) {
return glob.every((glob) => !minimatch(pkg.name, glob));
} else {
return glob.some((glob) => minimatch(pkg.name, glob));
}There was a problem hiding this comment.
I thought about doing that but didn't want to rock the boat in terms of the existing code. Agreed, that's much simpler, so I'll update the PR with that refactor. 👍
gigabo
left a comment
There was a problem hiding this comment.
Could maybe simplify to make it easier to read, but good fix! 👍
|
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Suppose we have:
package-apackage-bpackage-cThe following works as expected:
The message is:
And the following packages are bootstrapped:
package-cThe following does not work as expected:
The message is:
And the following packages are bootstrapped:
package-a(incorrect)package-b(incorrect)package-cThe latter glob is expanded to an array even before reaching
filterPackageinPackageUtilities. (Notice the difference in messages). However, the logic regarding negation (i.e.maybeNegate) was only withinglob.some, which would not work in the case thatglob.length > 1.This PR changes the boolean reducer depending on the desired negation (i.e.
Array.prototype.somefor the standard case, andArray.prototype.everyfor the negated case.