fix(core): fix terminal output for non-tui (#30957)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

vt100 does not work for non TUI

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

do not use vt100 for printing to stdout. vt100 is still used for the TUI
terminal panes.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jason Jean 2025-04-30 18:43:01 -04:00 committed by GitHub
parent 0f4c085297
commit fa92c4025e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,14 +110,20 @@ impl PseudoTerminal {
trace!("Quiet: {}", quiet); trace!("Quiet: {}", quiet);
debug!("Read {} bytes", len); debug!("Read {} bytes", len);
if let Ok(mut parser) = parser_clone.write() { if let Ok(mut parser) = parser_clone.write() {
let prev = parser.screen().clone();
parser.process(&buf[..len]); parser.process(&buf[..len]);
debug!("{}", parser.get_raw_output().len());
let write_buf = parser.screen().contents_diff(&prev);
if !quiet { if !quiet {
let mut logged_interrupted_error = false; let mut logged_interrupted_error = false;
let mut content = String::from_utf8_lossy(&buf[0..len]).to_string();
if content.contains("\x1B[6n") {
trace!("Prevented terminal escape sequence ESC[6n from being printed.");
content = content.replace("\x1B[6n", "");
}
let write_buf = content.as_bytes();
debug!("Escaped Stdout: {:?}", write_buf.escape_ascii().to_string());
while let Err(e) = stdout.write_all(&write_buf) { while let Err(e) = stdout.write_all(&write_buf) {
match e.kind() { match e.kind() {
std::io::ErrorKind::Interrupted => { std::io::ErrorKind::Interrupted => {