Skip to content

Commit 0e3c215

Browse files
committed
Don't prompt to install templates if not interactive
Signed-off-by: itowlson <[email protected]>
1 parent 13a133f commit 0e3c215

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/templates/src/manager.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::Path;
1+
use std::{io::IsTerminal, path::Path};
22

33
use anyhow::Context;
44

@@ -90,10 +90,11 @@ pub struct ListResults {
9090
}
9191

9292
impl ListResults {
93-
/// Returns true if no templates were found or skipped indicating that
94-
/// templates may not be installed.
93+
/// Returns true if no templates were found or skipped, and the UI should prompt to
94+
/// install templates. This is specifically for interactive use and returns false
95+
/// if not connected to a terminal.
9596
pub fn needs_install(&self) -> bool {
96-
self.templates.is_empty() && self.skipped.is_empty()
97+
self.templates.is_empty() && self.skipped.is_empty() && std::io::stderr().is_terminal()
9798
}
9899
}
99100

0 commit comments

Comments
 (0)