Skip to content

Commit

Permalink
chore: use standard IsTerminal (#5432)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jul 18, 2023
1 parent e41318d commit 058182d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ tracing-error = "0.2"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter", "fmt"] }
tracing = "0.1"
watchexec = "2"
is-terminal = "0.4"
comfy-table = "6"
reqwest = { version = "0.11", default-features = false, features = [
"json",
Expand Down
3 changes: 2 additions & 1 deletion cli/src/cmd/forge/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use once_cell::sync::Lazy;
use regex::Regex;
use semver::Version;
use std::{
io::IsTerminal,
path::{Path, PathBuf},
str,
};
Expand Down Expand Up @@ -316,7 +317,7 @@ impl Installer<'_> {

let mut is_branch = false;
// only try to match tag if current terminal is a tty
if is_terminal::is_terminal(std::io::stdout()) {
if std::io::stdout().is_terminal() {
if tag.is_empty() {
tag = self.match_tag(&tag, path)?;
} else if let Some(branch) = self.match_branch(&tag, path)? {
Expand Down
1 change: 0 additions & 1 deletion cli/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ethers = { workspace = true }
ethers-solc = { workspace = true, features = ["project-util"] }

eyre = "0.6"
is-terminal = "0.4"
once_cell = "1"
parking_lot = "0.12"
pretty_assertions = "1"
Expand Down
4 changes: 2 additions & 2 deletions cli/test-utils/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
fmt::Display,
fs,
fs::File,
io::{BufWriter, Write},
io::{BufWriter, IsTerminal, Write},
path::{Path, PathBuf},
process::{self, Command, Stdio},
sync::{
Expand All @@ -33,7 +33,7 @@ static CURRENT_DIR_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
static PRE_INSTALL_SOLC_LOCK: Lazy<Mutex<bool>> = Lazy::new(|| Mutex::new(false));

// This stores `true` if the current terminal is a tty
pub static IS_TTY: Lazy<bool> = Lazy::new(|| is_terminal::is_terminal(std::io::stdout()));
pub static IS_TTY: Lazy<bool> = Lazy::new(|| std::io::stdout().is_terminal());

/// Contains a `forge init` initialized project
pub static FORGE_INITIALIZED: Lazy<TestProject> = Lazy::new(|| {
Expand Down
1 change: 0 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ reqwest = { version = "0.11", default-features = false }
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
comfy-table = "6"
tracing = "0.1"
is-terminal = "0.4"
yansi = "0.5"
tempfile = "3"

Expand Down
10 changes: 3 additions & 7 deletions common/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use once_cell::sync::Lazy;
use semver::Version;
use std::{
io,
io::prelude::*,
io::{prelude::*, IsTerminal},
path::{Path, PathBuf},
sync::{
mpsc::{self, TryRecvError},
Expand Down Expand Up @@ -36,13 +36,9 @@ pub struct TermSettings {
}

impl TermSettings {
#[allow(missing_docs)]
/// Returns a new [`TermSettings`], configured from the current environment.
pub fn from_env() -> TermSettings {
if is_terminal::is_terminal(std::io::stdout()) {
TermSettings { indicate_progress: true }
} else {
TermSettings { indicate_progress: false }
}
TermSettings { indicate_progress: std::io::stdout().is_terminal() }
}
}

Expand Down

0 comments on commit 058182d

Please sign in to comment.