diff --git a/packages/nx/src/native/index.d.ts b/packages/nx/src/native/index.d.ts index 4318653faa..b08cd3989a 100644 --- a/packages/nx/src/native/index.d.ts +++ b/packages/nx/src/native/index.d.ts @@ -89,12 +89,12 @@ export declare class RunningTasksService { export declare class RustPseudoTerminal { constructor() - runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record | undefined | null, execArgv?: Array | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess + runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record | undefined | null, execArgv?: Array | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null, commandLabel?: string | undefined | null): ChildProcess /** * This allows us to run a pseudoterminal with a fake node ipc channel * this makes it possible to be backwards compatible with the old implementation */ - fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record | undefined | null, execArgv: Array | undefined | null, quiet: boolean): ChildProcess + fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record | undefined | null, execArgv: Array | undefined | null, quiet: boolean, commandLabel?: string | undefined | null): ChildProcess } export declare class TaskDetails { diff --git a/packages/nx/src/native/pseudo_terminal/mac.rs b/packages/nx/src/native/pseudo_terminal/mac.rs index ded8d0fe47..de2a0121b2 100644 --- a/packages/nx/src/native/pseudo_terminal/mac.rs +++ b/packages/nx/src/native/pseudo_terminal/mac.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use tracing::trace; +use watchexec::command; use super::child_process::ChildProcess; use super::os; @@ -31,9 +32,17 @@ impl RustPseudoTerminal { exec_argv: Option>, quiet: Option, tty: Option, + command_label: Option, ) -> napi::Result { - self.pseudo_terminal - .run_command(command, command_dir, js_env, exec_argv, quiet, tty) + self.pseudo_terminal.run_command( + command, + command_dir, + js_env, + exec_argv, + quiet, + tty, + command_label, + ) } /// This allows us to run a pseudoterminal with a fake node ipc channel @@ -48,6 +57,7 @@ impl RustPseudoTerminal { js_env: Option>, exec_argv: Option>, quiet: bool, + command_label: Option, ) -> napi::Result { let command = format!( "node {} {} {}", @@ -64,6 +74,7 @@ impl RustPseudoTerminal { exec_argv, Some(quiet), Some(true), + command_label, ) } } diff --git a/packages/nx/src/native/pseudo_terminal/non_mac.rs b/packages/nx/src/native/pseudo_terminal/non_mac.rs index 9aa2853dfb..0dc2177ed2 100644 --- a/packages/nx/src/native/pseudo_terminal/non_mac.rs +++ b/packages/nx/src/native/pseudo_terminal/non_mac.rs @@ -32,9 +32,17 @@ impl RustPseudoTerminal { exec_argv: Option>, quiet: Option, tty: Option, + command_label: Option, ) -> napi::Result { - self.pseudo_terminal - .run_command(command, command_dir, js_env, exec_argv, quiet, tty) + self.pseudo_terminal.run_command( + command, + command_dir, + js_env, + exec_argv, + quiet, + tty, + command_label, + ) } /// This allows us to run a pseudoterminal with a fake node ipc channel @@ -49,6 +57,7 @@ impl RustPseudoTerminal { js_env: Option>, exec_argv: Option>, quiet: bool, + command_label: Option, ) -> napi::Result { let command = format!( "node {} {} {}", @@ -65,6 +74,7 @@ impl RustPseudoTerminal { exec_argv, Some(quiet), Some(true), + command_label, ) } } diff --git a/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs b/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs index 636f4e074b..efbd38af43 100644 --- a/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs +++ b/packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs @@ -181,6 +181,7 @@ impl PseudoTerminal { exec_argv: Option>, quiet: Option, tty: Option, + command_label: Option, ) -> napi::Result { let command_dir = get_directory(command_dir)?; @@ -206,15 +207,15 @@ impl PseudoTerminal { let (exit_to_process_tx, exit_to_process_rx) = bounded(1); - let command_info = format!("> {}\n\n\r", command); + let command_clone = command.clone(); + let command_info = format!("> {}\n\n\r", command_label.unwrap_or(command)); self.stdout_tx.send(command_info.clone()).ok(); self.parser .write() .expect("Failed to acquire parser write lock") .process(command_info.as_bytes()); - - trace!("Running {}", command); + trace!("Running {}", command_clone); let mut child = pair.slave.spawn_command(cmd)?; self.running.store(true, Ordering::SeqCst); @@ -234,11 +235,11 @@ impl PseudoTerminal { trace!("spawning thread to wait for command"); std::thread::spawn(move || { - trace!("Waiting for {}", command); + trace!("Waiting for {}", command_clone); let res = child.wait(); if let Ok(exit) = res { - trace!("{} Exited", command); + trace!("{} Exited", command_clone); // This mitigates the issues with ConPTY on windows and makes it work. running_clone.store(false, Ordering::SeqCst); if cfg!(windows) { @@ -261,7 +262,7 @@ impl PseudoTerminal { } exit_to_process_tx.send(exit.to_string()).ok(); } else { - trace!("Error waiting for {}", command); + trace!("Error waiting for {}", command_clone); }; }); diff --git a/packages/nx/src/tasks-runner/forked-process-task-runner.ts b/packages/nx/src/tasks-runner/forked-process-task-runner.ts index a271b65c02..1ebf190a4b 100644 --- a/packages/nx/src/tasks-runner/forked-process-task-runner.ts +++ b/packages/nx/src/tasks-runner/forked-process-task-runner.ts @@ -203,6 +203,7 @@ export class ForkedProcessTaskRunner { execArgv: process.execArgv, jsEnv: env, quiet: !streamOutput, + commandLabel: `nx run ${task.id}`, }); p.send({ diff --git a/packages/nx/src/tasks-runner/pseudo-terminal.ts b/packages/nx/src/tasks-runner/pseudo-terminal.ts index ae2c4312a0..a82870e28e 100644 --- a/packages/nx/src/tasks-runner/pseudo-terminal.ts +++ b/packages/nx/src/tasks-runner/pseudo-terminal.ts @@ -106,11 +106,13 @@ export class PseudoTerminal { execArgv, jsEnv, quiet, + commandLabel, }: { cwd?: string; execArgv?: string[]; jsEnv?: Record; quiet?: boolean; + commandLabel?: string; } ) { if (!this.initialized) { @@ -125,7 +127,8 @@ export class PseudoTerminal { cwd, jsEnv, execArgv, - quiet + quiet, + commandLabel ), id, this.pseudoIPC