Skip to content

Commit

Permalink
chore(deps): Drop atty (#9325)
Browse files Browse the repository at this point in the history
Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
  • Loading branch information
SevereCloud and kdy1 authored Jul 24, 2024
1 parent f0bc1d2 commit 831500e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/shaggy-rats-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_cli_impl: patch
swc_common: patch
---

fix(deps): rm atty
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 @@ -51,7 +51,6 @@ resolver = "2"
arrayvec = "0.7.4"
assert_cmd = "2.0.12"
assert_fs = "1.0.13"
atty = "0.2.14"
auto_impl = "1.2.0"
backtrace = "0.3.61"
base64 = "0.21.0"
Expand Down
1 change: 0 additions & 1 deletion crates/swc_cli_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ plugin = [

[dependencies]
anyhow = { workspace = true }
atty = { workspace = true }
clap = { version = "3.2.25", features = ["derive", "wrap_help"] }
glob = { workspace = true }
path-absolutize = { workspace = true, features = ["once_cell_cache"] }
Expand Down
7 changes: 4 additions & 3 deletions crates/swc_cli_impl/src/commands/compile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
fs::{self, File},
io::{self, Read, Write},
io::{self, IsTerminal, Read, Write},
path::{Component, Path, PathBuf},
sync::Arc,
};
Expand Down Expand Up @@ -261,12 +261,13 @@ fn emit_output(
}

fn collect_stdin_input() -> Option<String> {
if atty::is(atty::Stream::Stdin) {
let stdin = io::stdin();
if stdin.is_terminal() {
return None;
}

let mut buffer = String::new();
let result = io::stdin().lock().read_to_string(&mut buffer);
let result = stdin.lock().read_to_string(&mut buffer);

if result.is_ok() && !buffer.is_empty() {
Some(buffer)
Expand Down
3 changes: 1 addition & 2 deletions crates/swc_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ plugin-rt = ["__plugin_rt", "plugin-base"]
plugin_transform_schema_v1 = []
plugin_transform_schema_vtest = []

tty-emitter = ["atty", "termcolor"]
tty-emitter = ["termcolor"]

__rkyv = []
rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "bytecheck"]
Expand All @@ -40,7 +40,6 @@ rkyv-impl = ["__rkyv", "rkyv", "swc_atoms/rkyv-impl", "bytecheck"]
ahash = { workspace = true, optional = true }
anyhow = { workspace = true, optional = true }
arbitrary = { workspace = true, features = ["derive"], optional = true }
atty = { workspace = true, optional = true }
# bytecheck version should be in sync with rkyv version. Do not bump individually.
bytecheck = { workspace = true, optional = true }
cfg-if = { workspace = true }
Expand Down
8 changes: 5 additions & 3 deletions crates/swc_common/src/errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
borrow::Cow,
cmp::{min, Reverse},
collections::HashMap,
io::{self, prelude::*},
io::{self, prelude::*, IsTerminal},
};

#[cfg(feature = "tty-emitter")]
Expand Down Expand Up @@ -116,16 +116,18 @@ pub enum ColorConfig {
impl ColorConfig {
#[cfg(feature = "tty-emitter")]
fn to_color_choice(self) -> ColorChoice {
let stderr = io::stderr();

match self {
ColorConfig::Always => {
if atty::is(atty::Stream::Stderr) {
if stderr.is_terminal() {
ColorChoice::Always
} else {
ColorChoice::AlwaysAnsi
}
}
ColorConfig::Never => ColorChoice::Never,
ColorConfig::Auto if atty::is(atty::Stream::Stderr) => ColorChoice::Auto,
ColorConfig::Auto if stderr.is_terminal() => ColorChoice::Auto,
ColorConfig::Auto => ColorChoice::Never,
}
}
Expand Down

0 comments on commit 831500e

Please sign in to comment.