Skip to content

Commit 443d240

Browse files
authoredMar 14, 2023
fix(atty): Switch out atty for is-terminal (#229)
1 parent ed486c9 commit 443d240

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed
 

‎Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ once_cell = "1.8.0"
1919
unicode-width = "0.1.9"
2020

2121
owo-colors = { version = "3.0.0", optional = true }
22-
atty = { version = "0.2.14", optional = true }
22+
is-terminal = { version = "0.4.0", optional = true }
2323
textwrap = { version = "0.15.0", optional = true }
24-
supports-hyperlinks = { version = "1.1.0", optional = true }
25-
supports-color = { version = "1.1.1", optional = true }
26-
supports-unicode = { version = "1.0.0", optional = true }
24+
supports-hyperlinks = { version = "2.0.0", optional = true }
25+
supports-color = { version = "2.0.0", optional = true }
26+
supports-unicode = { version = "2.0.0", optional = true }
2727
backtrace = { version = "0.3.61", optional = true }
2828
terminal_size = { version = "0.1.17", optional = true }
2929

@@ -43,7 +43,7 @@ lazy_static = "1.4"
4343
default = []
4444
fancy-no-backtrace = [
4545
"owo-colors",
46-
"atty",
46+
"is-terminal",
4747
"textwrap",
4848
"terminal_size",
4949
"supports-hyperlinks",

‎src/handler.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::fmt;
22

3-
use atty::Stream;
4-
53
use crate::protocol::Diagnostic;
64
use crate::GraphicalReportHandler;
75
use crate::GraphicalTheme;
@@ -193,12 +191,14 @@ impl MietteHandlerOpts {
193191
let characters = match self.unicode {
194192
Some(true) => ThemeCharacters::unicode(),
195193
Some(false) => ThemeCharacters::ascii(),
196-
None if supports_unicode::on(Stream::Stderr) => ThemeCharacters::unicode(),
194+
None if supports_unicode::on(supports_unicode::Stream::Stderr) => {
195+
ThemeCharacters::unicode()
196+
}
197197
None => ThemeCharacters::ascii(),
198198
};
199199
let styles = if self.color == Some(false) {
200200
ThemeStyles::none()
201-
} else if let Some(color) = supports_color::on(Stream::Stderr) {
201+
} else if let Some(color) = supports_color::on(supports_color::Stream::Stderr) {
202202
match self.rgb_colors {
203203
RgbColors::Always => ThemeStyles::rgb(),
204204
RgbColors::Preferred if color.has_16m => ThemeStyles::rgb(),
@@ -257,7 +257,7 @@ impl MietteHandlerOpts {
257257
if let Some(linkify) = self.linkify {
258258
linkify
259259
} else {
260-
supports_hyperlinks::on(Stream::Stderr)
260+
supports_hyperlinks::on(supports_hyperlinks::Stream::Stderr)
261261
}
262262
}
263263

‎src/handlers/theme.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use atty::Stream;
1+
use is_terminal::IsTerminal;
22
use owo_colors::Style;
33

44
/**
@@ -63,7 +63,9 @@ impl GraphicalTheme {
6363
impl Default for GraphicalTheme {
6464
fn default() -> Self {
6565
match std::env::var("NO_COLOR") {
66-
_ if !atty::is(Stream::Stdout) || !atty::is(Stream::Stderr) => Self::ascii(),
66+
_ if !std::io::stdout().is_terminal() || !std::io::stderr().is_terminal() => {
67+
Self::ascii()
68+
}
6769
Ok(string) if string != "0" => Self::unicode_nocolor(),
6870
_ => Self::unicode(),
6971
}

0 commit comments

Comments
 (0)
Please sign in to comment.