progress: Detect tty with std::io::IsTerminal, remove atty

Fixes https://github.com/advisories/GHSA-g98v-hv3f-hcfr.
This commit is contained in:
Zhaofeng Li 2024-11-08 11:44:10 -07:00
parent 936ed520eb
commit e73c6921fd
3 changed files with 3 additions and 3 deletions

1
Cargo.lock generated
View file

@ -234,7 +234,6 @@ version = "0.5.0-pre"
dependencies = [
"async-stream",
"async-trait",
"atty",
"clap",
"clap_complete",
"clicolors-control",

View file

@ -9,7 +9,6 @@ edition = "2021"
[dependencies]
async-stream = "0.3.5"
async-trait = "0.1.68"
atty = "0.2"
clap = { version = "4.3", features = ["derive"] }
clap_complete = "4.3"
clicolors-control = "1"

View file

@ -7,6 +7,8 @@
pub mod plain;
pub mod spinner;
use std::io::IsTerminal;
use async_trait::async_trait;
use tokio::sync::mpsc::{self, UnboundedReceiver as TokioReceiver, UnboundedSender as TokioSender};
@ -90,7 +92,7 @@ pub enum LineStyle {
impl SimpleProgressOutput {
pub fn new(verbose: bool) -> Self {
let tty = atty::is(atty::Stream::Stdout);
let tty = std::io::stdout().is_terminal();
if verbose || !tty {
Self::Plain(PlainOutput::new())