Skip to content

Commit

Permalink
Merge pull request #1508 from tottoto/replace-atty-with-is-terminal
Browse files Browse the repository at this point in the history
chore: replace atty with is-terminal
  • Loading branch information
chriskrycho authored Dec 19, 2023
2 parents 589116d + e3a4a20 commit eace466
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
55 changes: 47 additions & 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name = "volta-migrate"
path = "src/volta-migrate.rs"

[dependencies]
atty = "0.2"
is-terminal = "0.4.7"
volta-core = { path = "crates/volta-core" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.96"
Expand Down
2 changes: 1 addition & 1 deletion crates/volta-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dirs = "5.0.0"
chrono = "0.4.23"
validate-npm-package-name = { path = "../validate-npm-package-name" }
textwrap = "0.16.0"
atty = "0.2"
is-terminal = "0.4.7"
log = { version = "0.4", features = ["std"] }
ctrlc = "3.2.5"
walkdir = "2.3.2"
Expand Down
4 changes: 2 additions & 2 deletions crates/volta-core/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module provides a custom Logger implementation for use with the `log` crate
use atty::Stream;
use console::style;
use is_terminal::IsTerminal;
use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError};
use std::env;
use std::fmt::Display;
Expand Down Expand Up @@ -146,7 +146,7 @@ fn level_from_env() -> LevelFilter {
.ok()
.and_then(|level| level.to_uppercase().parse().ok())
.unwrap_or_else(|| {
if atty::is(Stream::Stdout) {
if std::io::stdout().is_terminal() {
LevelFilter::Info
} else {
LevelFilter::Error
Expand Down
3 changes: 2 additions & 1 deletion src/command/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod toolchain;

use std::{fmt, path::PathBuf, str::FromStr};

use is_terminal::IsTerminal as _;
use semver::Version;
use structopt::StructOpt;

Expand Down Expand Up @@ -265,7 +266,7 @@ impl List {
// have, that trumps our TTY-checking. Then, if the user has *not*
// specified an option, we use `Human` mode for TTYs and `Plain` for
// non-TTY contexts.
self.format.unwrap_or(if atty::is(atty::Stream::Stdout) {
self.format.unwrap_or(if std::io::stdout().is_terminal() {
Format::Human
} else {
Format::Plain
Expand Down

0 comments on commit eace466

Please sign in to comment.