-
-
Notifications
You must be signed in to change notification settings - Fork 620
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
Migrate to colorette 2.0.x #2956
Conversation
|
@@ -1,6 +1,22 @@ | |||
let colorette = null; |
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.
Why we need this?
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.
To avoid recreating colorette instance on every getter call. We could simply import default colouring operations, but these would default to always on and ignore configuration overrides.
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.
We decided to classify the always-color behavior as a bug after all (jorgebucaran/colorette#72). If you don't really care about the new createColors
API, you may continue using Colorette as you were before, just upgrade to 2.0.5
or later.
const col = require('colorette'); | ||
const options = { | ||
changed: false, | ||
enabled: colorette? colorette.options.enabled : true, |
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.
It seems some weird, colorette already has logic for enabled
, why we need check colorette
?
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.
See existing code at
cli.utils.colors.options.changed = true; |
From my understanding this is an existing solution to trigger changes in the behaviour of instance, returned by getter. Alternatively, we can expose a method that would instantly recreate instance, stored here, to avoid this.
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.
We should rewrite logic, because we already cache module, we can keep changed
on object level
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.
caching module is not enough, we need to store initialized coloretto instance as well
Codecov Report
@@ Coverage Diff @@
## master #2956 +/- ##
=======================================
Coverage 95.13% 95.13%
=======================================
Files 31 31
Lines 1684 1684
Branches 483 483
=======================================
Hits 1602 1602
Misses 82 82 Continue to review full report at Codecov.
|
@@ -1,6 +1,22 @@ | |||
let colorette = null; |
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.
We decided to classify the always-color behavior as a bug after all (jorgebucaran/colorette#72). If you don't really care about the new createColors
API, you may continue using Colorette as you were before, just upgrade to 2.0.5
or later.
|
superseded by #2966 |
fixes #2955
Update colorette to a new semver major version.
Did you add tests for your changes?
Not relevant.
If relevant, did you update the documentation?
Not relevant.
Summary
This ensures webpack-cli is staying on up-to-date dependency version, and also removes reliance on global state, which is never a good idea.
Does this PR introduce a breaking change?
It shouldn't, although there was a change in colorette behavior: it no longer generates colouring for empty strings, which is unlikely to be an issue for majority of users.