Skip to content

Commit d170bd2

Browse files
authored
Replace 'atty' dependency with 'is-terminal' (#145)
1 parent cfd6897 commit d170bd2

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased
2+
3+
# 2.0.2
24
- Fix typo in `src/control.rs`.
5+
- Replace `atty` dependency with `is-terminal`.
36

47
# 2.0.1 (July 3, 2023)
58
- Add edition for future compatibility.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "colored"
33
description = "The most simple way to add colors in your terminal"
4-
version = "2.0.1"
4+
version = "2.0.2"
55
edition = "2021"
66
authors = ["Thomas Wickham <[email protected]>"]
77
license = "MPL-2.0"
@@ -15,7 +15,7 @@ keywords = ["color", "string", "term", "ansi_term", "term-painter"]
1515
no-color = []
1616

1717
[dependencies]
18-
atty = "0.2"
18+
is-terminal = "0.4"
1919
lazy_static = "1"
2020

2121
[target.'cfg(windows)'.dependencies.winapi]

src/control.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! A couple of functions to enable and disable coloring.
22
3+
use is_terminal::IsTerminal;
34
use std::default::Default;
45
use std::env;
6+
use std::io;
57
use std::sync::atomic::{AtomicBool, Ordering};
68

79
/// Sets a flag to the console to use a virtual terminal environment.
@@ -105,7 +107,7 @@ impl ShouldColorize {
105107
pub fn from_env() -> Self {
106108
ShouldColorize {
107109
clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true)
108-
&& atty::is(atty::Stream::Stdout),
110+
&& io::stdout().is_terminal(),
109111
clicolor_force: ShouldColorize::resolve_clicolor_force(
110112
env::var("NO_COLOR"),
111113
env::var("CLICOLOR_FORCE"),

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//!
2626
#![warn(missing_docs)]
2727

28-
extern crate atty;
28+
extern crate is_terminal;
2929
#[macro_use]
3030
extern crate lazy_static;
3131
#[cfg(windows)]

0 commit comments

Comments
 (0)