Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Replace atty with is-terminal #18966

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -341,7 +341,7 @@ mlua = { version = "0.9.1", default-features = false, features = ["lua54", "send
windows-service = "0.6.0"

[target.'cfg(unix)'.dependencies]
atty = { version = "0.2.14", default-features = false }
is-terminal = { version = "0.4", default-features = false }
nix = { version = "0.26.2", default-features = false, features = ["socket", "signal"] }

[build-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion src/cli.rs
Expand Up @@ -331,9 +331,10 @@ pub enum Color {

impl Color {
pub fn use_color(&self) -> bool {
use is_terminal::IsTerminal;
match self {
#[cfg(unix)]
Color::Auto => atty::is(atty::Stream::Stdout),
Color::Auto => std::io::stdout().is_terminal(),
#[cfg(windows)]
Color::Auto => false, // ANSI colors are not supported by cmd.exe
Color::Always => true,
Expand Down
5 changes: 4 additions & 1 deletion src/test_util/mod.rs
Expand Up @@ -122,7 +122,10 @@ pub fn next_addr_v6() -> SocketAddr {

pub fn trace_init() {
#[cfg(unix)]
let color = atty::is(atty::Stream::Stdout);
let color = {
use is_terminal::IsTerminal;
std::io::stdout().is_terminal()
};
// Windows: ANSI colors are not supported by cmd.exe
// Color is false for everything except unix.
#[cfg(not(unix))]
Expand Down
2 changes: 1 addition & 1 deletion vdev/Cargo.toml
Expand Up @@ -9,7 +9,7 @@ publish = false

[dependencies]
anyhow = "1.0.75"
atty = "0.2.14"
is-terminal = { version = "0.4" }
cached = "0.46.0"
chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] }
clap = { version = "4.4.7", features = ["derive"] }
Expand Down
3 changes: 2 additions & 1 deletion vdev/src/util.rs
Expand Up @@ -3,11 +3,12 @@ use std::process::{Command, Output};
use std::{collections::BTreeMap, fmt::Debug, fs, io::ErrorKind, path::Path};

use anyhow::{Context as _, Result};
use is_terminal::IsTerminal;
use once_cell::sync::Lazy;
use serde::Deserialize;
use serde_json::Value;

pub static IS_A_TTY: Lazy<bool> = Lazy::new(|| atty::is(atty::Stream::Stdout));
pub static IS_A_TTY: Lazy<bool> = Lazy::new(|| std::io::stdout().is_terminal());

#[derive(Deserialize)]
pub struct CargoTomlPackage {
Expand Down