From db8be2d6bbb3b67e305b59d2e827d768aa25edf0 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Fri, 17 May 2024 22:33:26 +0100 Subject: [PATCH] chore: check we are in terminal before creating one I tried to run `node-launchpad` in a headless VM and it said it couldn't find a terminal. We don't need to find a terminal if we are already running in one, so the check here is changed slightly. We will probably want to reconfigure the elevated privilege to be a separate thing from configuring a terminal, but on Windows this will be a bit more complex and will better be done as a separate piece of work. --- node-launchpad/src/bin/tui/main.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/node-launchpad/src/bin/tui/main.rs b/node-launchpad/src/bin/tui/main.rs index ce50fffdc0..35949dd425 100644 --- a/node-launchpad/src/bin/tui/main.rs +++ b/node-launchpad/src/bin/tui/main.rs @@ -58,15 +58,11 @@ fn is_running_in_terminal() -> bool { #[tokio::main] async fn main() -> Result<()> { - // now launch the terminal - let terminal_type = terminal::detect_and_setup_terminal()?; - if !is_running_in_terminal() { + // If we weren't already running in a terminal, this process returns early, having spawned + // a new process that launches a terminal. + let terminal_type = terminal::detect_and_setup_terminal()?; terminal::launch_terminal(&terminal_type)?; - - // early return for _this_ process. - // The spawned process will be sudo'd and run in the terminal, - // taking over stdout/stderr/stdin. return Ok(()); }