Skip to content
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

Use appropriate chalk instance for stderr output #13098

Merged
merged 1 commit into from
Jul 13, 2022
Merged

Use appropriate chalk instance for stderr output #13098

merged 1 commit into from
Jul 13, 2022

Conversation

dspinellis
Copy link
Contributor

Chalk auto-detects whether the output channel supports colors, but does that for stderr. Consequently, colors appear inconsistently (and wrongly) depending on whether stdout or stderr have been redirected.

Issue: #13097

Description

This change corrects the instance of chalk used, according to the employed output channel (stdout or stderr).

Checklist

  • I manually tested the result. I also tried adding tests to confirm my change works in three ways, but none is viable. Specifically, I tried the following:
    • via changes to run-pretties.js (its existing process.stdin.isTTY code is bogus, because chalk calls directly isatty()),
    • via mocking (it doesn't work, because chalk sets the values at the module level), and
    • by modifying the chalk object with Object.defineProperty (it doesn't work, because the configurable is set to false).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Chalk auto-detects whether the output channel supports colors,
but does that for stderr.  Consequently, colors appear inconsistently
(and wrongly) depending on whether stdout or stderr have been redirected.

Issue: #13097
Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

@sosukesuzuki sosukesuzuki merged commit e5beb5a into prettier:main Jul 13, 2022
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Jan 4, 2024
Chalk auto-detects whether the output channel supports colors,
but does that for stderr.  Consequently, colors appear inconsistently
(and wrongly) depending on whether stdout or stderr have been redirected.

Issue: prettier#13097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants