Skip to content

Commit

Permalink
chore: check we are in terminal before creating one
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jacderida authored and joshuef committed May 19, 2024
1 parent 7248531 commit db8be2d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions node-launchpad/src/bin/tui/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down

0 comments on commit db8be2d

Please sign in to comment.