From 0279b7d02c40b060d5d5881f993bb57ae3ab1da3 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Mon, 8 Oct 2018 14:39:16 -0300 Subject: [PATCH] Replace `isatty` crate with `atty` The `isatty` crate has been deprecated and a replacement has been released for it called `atty`. It offers a nicer API and the code change to adapt is trivial. Signed-off-by: Otavio Salvador --- Cargo.lock | 14 +------------- Cargo.toml | 2 +- src/config/options.rs | 4 ++-- src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a6380d1bdf..558b12dfa28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,17 +245,6 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "isatty" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itertools" version = "0.7.8" @@ -603,13 +592,13 @@ name = "rustfmt-nightly" version = "0.99.5" dependencies = [ "assert_cli 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -876,7 +865,6 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" -"checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" diff --git a/Cargo.toml b/Cargo.toml index 44646bdd4d9..0359917d67a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ cargo-fmt = [] rustfmt-format-diff = [] [dependencies] -isatty = "0.1" +atty = "0.2" itertools = "0.7" toml = "0.4" serde = "1.0" diff --git a/src/config/options.rs b/src/config/options.rs index 34b6ea0dde6..a4ba21b53cf 100644 --- a/src/config/options.rs +++ b/src/config/options.rs @@ -12,7 +12,7 @@ use config::config_type::ConfigType; use config::lists::*; use config::{Config, FileName}; -use isatty::stdout_isatty; +use atty; use std::collections::HashSet; use std::path::{Path, PathBuf}; @@ -297,7 +297,7 @@ impl Color { match self { Color::Always => true, Color::Never => false, - Color::Auto => stdout_isatty(), + Color::Auto => atty::is(atty::Stream::Stdout), } } } diff --git a/src/lib.rs b/src/lib.rs index e77eacb5c34..b8f9d4cfb6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,9 +16,9 @@ #[macro_use] extern crate derive_new; +extern crate atty; extern crate diff; extern crate failure; -extern crate isatty; extern crate itertools; #[cfg(test)] #[macro_use]