-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix!: use stdin to infer colors instead of stdout #10860
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@wesleytodd is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
| _ => None, | ||
| }); | ||
| let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdout)); | ||
| let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdin)); |
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.
| let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdin)); | |
| let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdout)); |
The color detection logic incorrectly checks stdin instead of stdout for TTY status, which breaks color output in common shell redirection scenarios.
View Details
Analysis
ColorConfig::infer() checks stdin instead of stdout for TTY, breaking shell redirection
What fails: ColorConfig::infer() in crates/turborepo-ui/src/lib.rs:167 uses atty::is(atty::Stream::Stdin) instead of atty::is(atty::Stream::Stdout) for color output decisions
How to reproduce:
# Should show colors but won't (stdin is not TTY, stdout is TTY):
echo "data" | turborepo build
# Should disable colors but won't (stdin is TTY, stdout is not TTY):
turborepo build > logfile.txtResult: Colors are incorrectly enabled/disabled based on input source rather than output destination, causing missing colors in pipelines and ANSI codes polluting log files
Expected: Color decisions should check stdout TTY status per atty documentation examples and standard Unix convention - colors are output to stdout/stderr, so output stream TTY status determines color support
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.
lol, well this is funny. This check breaks my use case. I assume this is some AI comment, so I will wait for a human to address this.
|
Hey, Wes, thanks for the PR. I'm a little suspicious of the semantics here. I think of Example: I might not be realizing if this is common behavior, though. Do you have examples of tools that do this? Another thing is that we have |
Description
Checking
stdinwould allow for cases wherestdoutis redirected but you still want colors to be maintained (which is rather common IME). Since it is relatively less common (and there are few workarounds other than settingFORCE_COLORSthat I know of) to havestdinbe a TTY but still want colors, it seems like this would be a good change for the next major. It is a breaking change, so totally understand if it would need to wait.Testing Instructions
I didn't even test this, but happy to if you think this has a chance of landing.