Skip to content

Commit 637a9a3

Browse files
authored
Merge pull request #2558 from itowlson/templates-dont-prompt-to-install-if-not-interactive
Don't prompt to install templates if not interactive
2 parents 98aa3e4 + 0e3c215 commit 637a9a3

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)