Skip to content

Commit

Permalink
Replace 'atty' dependency with 'is-terminal' (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwittenborn authored Jul 5, 2023
1 parent cfd6897 commit d170bd2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

# 2.0.2
- Fix typo in `src/control.rs`.
- Replace `atty` dependency with `is-terminal`.

# 2.0.1 (July 3, 2023)
- Add edition for future compatibility.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "colored"
description = "The most simple way to add colors in your terminal"
version = "2.0.1"
version = "2.0.2"
edition = "2021"
authors = ["Thomas Wickham <mackwic@gmail.com>"]
license = "MPL-2.0"
Expand All @@ -15,7 +15,7 @@ keywords = ["color", "string", "term", "ansi_term", "term-painter"]
no-color = []

[dependencies]
atty = "0.2"
is-terminal = "0.4"
lazy_static = "1"

[target.'cfg(windows)'.dependencies.winapi]
Expand Down
4 changes: 3 additions & 1 deletion src/control.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -105,7 +107,7 @@ impl ShouldColorize {
pub fn from_env() -> Self {
ShouldColorize {
clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true)
&& atty::is(atty::Stream::Stdout),
&& io::stdout().is_terminal(),
clicolor_force: ShouldColorize::resolve_clicolor_force(
env::var("NO_COLOR"),
env::var("CLICOLOR_FORCE"),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//!
#![warn(missing_docs)]

extern crate atty;
extern crate is_terminal;
#[macro_use]
extern crate lazy_static;
#[cfg(windows)]
Expand Down

0 comments on commit d170bd2

Please sign in to comment.