From dfa0ea73849dd24e2870cfa83dd9d8f68ebbbe6a Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Fri, 26 Apr 2024 15:31:36 -0400 Subject: [PATCH] fix(core): prevent device status report from being printed during pty execution --- .../src/native/pseudo_terminal/pseudo_terminal.rs | 15 ++++++++++++++- packages/nx/src/utils/command-line-utils.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs b/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs index d30ff76a04a9f..2a5471d41e10f 100644 --- a/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs +++ b/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs @@ -81,7 +81,12 @@ pub fn create_pseudo_terminal() -> napi::Result { 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(); @@ -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); @@ -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(), diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index 1208c6c51b1d5..c6241de5f809b 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -39,7 +39,7 @@ export interface NxArgs { } export function createOverrides(__overrides_unparsed__: string[] = []) { - let overrides = + let overrides: Record = yargsParser(__overrides_unparsed__, { configuration: { 'camel-case-expansion': false,