Add option to ignore packages when bootstrapping (fixes #117)#168
Add option to ignore packages when bootstrapping (fixes #117)#168hzoo merged 4 commits intolerna:masterfrom
Conversation
|
I think potentially we could use the |
|
@joscha hmm, edit: for comparison, the babel cli has |
|
@rygine you are right, I guess it might be confusing ;) |
|
Sorry about the confusion with flag names, I don't want it to turn into a mess, but haven't really thought about it holistically. |
3ead3e3 to
b4223d2
Compare
|
the more i think about it, the more inclined i am make the flag name more generic. i think i like the way |
|
I am happy to work on it to make it work for both black- and whitelisting. Cheers,
|
3a235fb to
3b1eed5
Compare
|
@joscha: I've added another commit that renames the flag to @thejameskyle: I remember you saying that you didn't want an |
|
This would be really useful. Please let me know if I can help in any way. |
|
@rygine @thejameskyle does that mean I should rename the flag in #152 to |
|
this LGTM |
a928273 to
ae5df47
Compare
|
@hzoo @joscha @thejameskyle i've updated the PR to include usage of i settled on the new i can do a PR for adding scope to the bootstrap command after this is merged. |
| static filterPackages(packages, glob, negate = false) { | ||
| if (typeof glob !== "undefined") { | ||
| packages = packages.filter(pkg => minimatch(pkg.name, glob)); | ||
| packages = packages.filter(pkg => negate ? !minimatch(pkg.name, glob) : minimatch(pkg.name, glob)); |
There was a problem hiding this comment.
isn't that an xor? negate ^ minimatch(pkg.name, glob) should do it I think.
There was a problem hiding this comment.
i knew there was a better way. this works! thanks. amending...
|
@rygine nice! What if you specify both |
|
@joscha i think specifying both should throw an error so that there's no confusion as to what gets precedence. |
ae5df47 to
30f928b
Compare
| static filterPackages(packages, glob, negate = false) { | ||
| if (typeof glob !== "undefined") { | ||
| packages = packages.filter(pkg => minimatch(pkg.name, glob)); | ||
| packages = packages.filter(pkg => negate ^ minimatch(pkg.name, glob)); |
There was a problem hiding this comment.
I think theres approximately 7 people in the universe that know what the ^ operator does. I'd rather have something longer that expresses what happens better.
There was a problem hiding this comment.
😂 I think the name of the variable kinda gives the functionality away though...
There was a problem hiding this comment.
should i go back to the ternary operator i had before?
packages = packages.filter(pkg => negate ? !minimatch(pkg.name, glob) : minimatch(pkg.name, glob));There was a problem hiding this comment.
Either that or just a if else
packages.filter(pkg => {
if (negate) {
} else {
}
}There was a problem hiding this comment.
I know what they do and how to read them if I need to, but I also 100% agree that they are unreadable and unclear unless you're actually doing bitwise math.
There was a problem hiding this comment.
if minimatch returns a boolean, couldn't ^ simply be replaced with !==? in case the operator is the issue.
|
@rygine fair enough, I guess the use case for such a thing is very slim anyway, as you can always express one through the other or just use a more specific glob. |
|
👍 Can you add a corresponding readme update? |
0f411f4 to
5cd1b0f
Compare
|
@hzoo docs added |
|
Can you rebase again? |
* Added `ignore` flag to CLI * Check `bootstrapConfig.ignore` key in `lerna.json` The CLI flag will override the `bootstrapConfig` option in `lerna.json`. Both the flag and the option accept a glob pattern of package names to ignore.
Used a simple `if` statement rather than a ternary or bitwise XOR operator when filtering packages.
c3c7b1c to
f9664c4
Compare
|
done |
|
needed to update the stub in the a unit test. should be good now. |
|
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. |
ignoreflag to CLIbootstrapConfig.ignorekey inlerna.jsonThe CLI flag will override the
bootstrapConfigoption inlerna.json. Both the flag and the option accept a glob pattern of package names to ignore.this is the new PR from my company's github org