From 02cc0e08dc3969c821a97f11e8bb52a8a6d7adb6 Mon Sep 17 00:00:00 2001 From: Hunter Wittenborn Date: Mon, 24 Jul 2023 09:31:53 -0500 Subject: [PATCH] Replace 'atty' dependency with 'is-terminal' --- CHANGELOG.md | 2 ++ Cargo.toml | 6 +++--- src/control.rs | 4 +++- src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db17669..4c272b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# 1.9.4 (July 24, 2023) +- Replace 'atty' dependency with 'is-terminal' # 1.9.3 (February 24, 2020) - Fix compilation regression for 1.34.0. Thanks @jlevon for reporting. diff --git a/Cargo.toml b/Cargo.toml index 0b62d97..3a6a1a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "colored" description = "The most simple way to add colors in your terminal" -version = "1.9.2" +version = "1.9.4" authors = ["Thomas Wickham "] license = "MPL-2.0" homepage = "https://github.com/mackwic/colored" @@ -14,8 +14,8 @@ keywords = ["color", "string", "term", "ansi_term", "term-painter"] no-color = [] [dependencies] -atty = "0.2.11" -lazy_static = "1.4.0" +is-terminal = "0.4" +lazy_static = "1" [target.'cfg(windows)'.dependencies.winapi] version = "0.3" diff --git a/src/control.rs b/src/control.rs index 7ad6e62..f564162 100644 --- a/src/control.rs +++ b/src/control.rs @@ -1,7 +1,9 @@ //! A couple of functions to enable and disable coloring. +use is_terminal::IsTerminal; use std::default::Default; use std::env; +use std::io; use std::sync::atomic::{AtomicBool, Ordering}; /// Sets a flag to the console to use a virtual terminal environment. @@ -105,7 +107,7 @@ impl ShouldColorize { pub fn from_env() -> Self { ShouldColorize { clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or_else(|| true) - && atty::is(atty::Stream::Stdout), + && io::stdout().is_terminal(), clicolor_force: ShouldColorize::resolve_clicolor_force( env::var("NO_COLOR"), env::var("CLICOLOR_FORCE"), diff --git a/src/lib.rs b/src/lib.rs index fe70a08..ae32f4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ //! #![warn(missing_docs)] -extern crate atty; +extern crate is_terminal; #[macro_use] extern crate lazy_static; #[cfg(windows)]