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

fix(core): prevent device status report from being printed during pty execution #23039

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ pub fn create_pseudo_terminal() -> napi::Result<PseudoTerminal> {
let quiet = quiet_clone.load(Ordering::Relaxed);
trace!("Quiet: {}", quiet);
if !quiet {
if stdout.write_all(&buf[0..len]).is_err() {
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", "");
}
if stdout.write_all(content.as_bytes()).is_err() {
break;
} else {
let _ = stdout.flush();
Expand Down Expand Up @@ -141,8 +146,12 @@ pub fn run_command(
}
let process_killer = child.clone_killer();

trace!("Getting running clone");
let running_clone = pseudo_terminal.running.clone();
trace!("Getting printing_rx clone");
let printing_rx = pseudo_terminal.printing_rx.clone();

trace!("spawning thread to wait for command");
std::thread::spawn(move || {
trace!("Waiting for {}", command);

Expand All @@ -165,12 +174,16 @@ pub fn run_command(
}
}
if is_tty {
trace!("Disabling raw mode");
disable_raw_mode().expect("Failed to restore non-raw terminal");
}
exit_to_process_tx.send(exit.to_string()).ok();
} else {
trace!("Error waiting for {}", command);
};
});

trace!("Returning ChildProcess");
Ok(ChildProcess::new(
process_killer,
pseudo_terminal.message_rx.clone(),
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/utils/command-line-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface NxArgs {
}

export function createOverrides(__overrides_unparsed__: string[] = []) {
let overrides =
let overrides: Record<string, any> =
yargsParser(__overrides_unparsed__, {
configuration: {
'camel-case-expansion': false,
Expand Down