-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Deprecate chalk.constructor()
in favor of new chalk.Instance()
#322
Conversation
Can you add some tests? |
And update all the references to
|
You also need to update the TypeScript and Flow type definition. |
Add a dummy function that throws a helpful error. |
instance()
method to support new Chalk.instance()
Should we make it |
Thanks, I'll make these changes. Tests are failing due to that exact problem, the other solution I can think of is to expose a helper function of
|
instance()
method to support new Chalk.instance()
Instance()
method to support new Chalk.Instance()
@sindresorhus I've changed all references to use a capital letter ( |
index.js
Outdated
return chalk.template; | ||
} | ||
chalk.template.constructor = () => { | ||
throw new Error('Chalk.constructor() is deprecated. Use new Chalk.Instance() instead.'); |
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.
throw new Error('Chalk.constructor() is deprecated. Use new Chalk.Instance() instead.'); | |
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.'); |
readme.md
Outdated
@@ -140,12 +140,12 @@ Multiple arguments will be separated by space. | |||
|
|||
Color support is automatically detected, as is the level (see `chalk.level`). However, if you'd like to simply enable/disable Chalk, you can do so via the `.enabled` property. When `chalk.enabled` is `true`, `chalk.level` must *also* be greater than `0` for colored output to be produced. | |||
|
|||
Chalk is enabled by default unless explicitly disabled via the constructor or `chalk.level` is `0`. | |||
Chalk is enabled by default unless explicitly disabled via `Chalk.Instance()` or `chalk.level` is `0`. |
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.
Chalk is enabled by default unless explicitly disabled via `Chalk.Instance()` or `chalk.level` is `0`. | |
Chalk is enabled by default unless explicitly disabled via `new chalk.Instance()` or `chalk.level` is `0`. |
Sorry, this got totally lost in my open tabs. |
@sindresorhus No problem! I've made the suggested changes. |
Instance()
method to support new Chalk.Instance()
chalk.constructor()
in favor of new chalk.Instance()
Thank you! :) |
As a new chalk user, I've got to ask: why? What was wrong with |
|
@Qix- Okay, but this doesn't explain what was actually wrong with it. How does moving to new |
Because chalk was already an instance of chalk. Using new on it doesn't make much semantic sense. But moreover, IIRC there was a limitation with using new chalk, something with the template parser. |
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.
Screws Stuff Up For Me
@grunge6 Please raise an issue with replication steps if you have found a bug or would like some support 😄 |
@grunge6 Such is OSS. We can't retain backwards compatibility forever, especially when we are careful about following semantic versioning. If there is a bug, please open a new issue so we can address it. Be sure to include all of the relevant information (such as how to reproduce the bug). Locking this as there is nothing further actionable. |
Closes #188
Todo:
chalk.constructor()
Here is the output from
npm run bench
:Compared to current version of chalk: