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
Fix --ignore flag when globs are expanded to an array #601
Conversation
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.
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. 🎉 |
src/PackageUtilities.js
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 👍
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.
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-a
package-b
package-c
The following works as expected:
The message is:
And the following packages are bootstrapped:
package-c
The following does not work as expected:
The message is:
And the following packages are bootstrapped:
package-a
(incorrect)package-b
(incorrect)package-c
The latter glob is expanded to an array even before reaching
filterPackage
inPackageUtilities
. (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.some
for the standard case, andArray.prototype.every
for the negated case.