Skip to content

Commit

Permalink
chore: remove atty (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Sep 21, 2023
1 parent f8ced5c commit 50557de
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ biome_text_size = { version = "0.0.1", path = "./crates/biome_text_
tests_macros = { path = "./crates/tests_macros" }

# Crates needed in the workspace
atty = "0.2.14"
bitflags = "2.3.1"
bpaf = { version = "0.9.5", features = ["derive"] }
countme = "3.0.1"
Expand Down
1 change: 0 additions & 1 deletion crates/biome_console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version = "0.0.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
atty = { workspace = true }
biome_markup = { workspace = true }
biome_text_size = { workspace = true }
schemars = { workspace = true, optional = true }
Expand Down
9 changes: 4 additions & 5 deletions crates/biome_console/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use atty::Stream;
use std::io;
use std::io::{Read, Stdin, Write};
use std::io::{stderr, stdin, stdout, IsTerminal, Read, Stdin, Write};
use std::panic::RefUnwindSafe;
use termcolor::{ColorChoice, StandardStream};
use write::Termcolor;
Expand Down Expand Up @@ -97,13 +96,13 @@ impl EnvConsole {
ColorMode::Enabled => (ColorChoice::Always, ColorChoice::Always),
ColorMode::Disabled => (ColorChoice::Never, ColorChoice::Never),
ColorMode::Auto => {
let stdout = if atty::is(atty::Stream::Stdout) {
let stdout = if stdout().is_terminal() {
ColorChoice::Auto
} else {
ColorChoice::Never
};

let stderr = if atty::is(atty::Stream::Stderr) {
let stderr = if stderr().is_terminal() {
ColorChoice::Auto
} else {
ColorChoice::Never
Expand Down Expand Up @@ -169,7 +168,7 @@ impl Console for EnvConsole {
//
// Doing this check allows us to pipe stdin to rome, without expecting
// user content when we call `read_to_string`
if atty::is(Stream::Stdin) {
if stdin().is_terminal() {
return None;
}
let mut handle = self.r#in.lock();
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_js_parser/src/lexer/highlight.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::*;
use std::io::{stderr, stdout, IsTerminal};

pub use ansi_term::{self, ANSIGenericString, Color, Style};
use atty::is;

/// A structure for syntax highlighting pieces of JavaScript source code
/// using ANSI.
Expand Down Expand Up @@ -44,7 +44,7 @@ impl<'s> Highlighter<'s> {
}

fn check_terminal(&self) -> bool {
is(atty::Stream::Stderr) && is(atty::Stream::Stdout)
stderr().is_terminal() && stdout().is_terminal()
}

/// Reset the highlighter to the start of the source code
Expand Down
1 change: 0 additions & 1 deletion xtask/coverage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ version = "0.0.0"

[dependencies]
ascii_table = "4.0.2"
atty = { workspace = true }
backtrace = "0.3.65"
biome_console = { path = "../../crates/biome_console" }
biome_diagnostics = { path = "../../crates/biome_diagnostics" }
Expand Down
5 changes: 2 additions & 3 deletions xtask/coverage/src/reporters.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::runner::{TestCaseFiles, TestRunOutcome, TestRunResult, TestSuite, TestSuiteInstance};
use crate::{Summary, TestResults};
use ascii_table::{Align, AsciiTable};
use atty::Stream;
use biome_diagnostics::termcolor::Buffer;
use biome_diagnostics::{DiagnosticExt, Error};
use colored::Colorize;
use indicatif::ProgressBar;
use serde_json::Value;
use std::collections::HashMap;
use std::io::Write;
use std::io::{stdout, IsTerminal, Write};
use std::str::FromStr;
use std::time::Instant;

Expand Down Expand Up @@ -186,7 +185,7 @@ impl Write for OutputTarget {

impl SummaryReporter {
pub fn new(detail_level: SummaryDetailLevel, output_target: OutputTarget) -> Self {
let buffer = if atty::is(Stream::Stdout) {
let buffer = if stdout().is_terminal() {
Buffer::ansi()
} else {
// piping to a file
Expand Down

0 comments on commit 50557de

Please sign in to comment.