Skip to content

Commit 5d96ef3

Browse files
build: move from attyis-terminal
Partially resolves this [RustSec advisory](https://rustsec.org/advisories/RUSTSEC-2021-0145.html).
1 parent 0d0f1b3 commit 5d96ef3

File tree

4 files changed

+151
-13
lines changed

4 files changed

+151
-13
lines changed

Cargo.lock

Lines changed: 144 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ clap = { version = "3.0", features = ["derive"] }
1616
clap_complete = "3.0"
1717

1818
[dependencies]
19-
atty = "~0.2.11"
2019
clap = { version = "3.0", features = ["derive"] }
20+
is-terminal = "0.4.9"
2121
num_cpus = "1"
2222
rayon = "~1.4.0"
2323
regex = "1"

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use atty;
21
use clap::Parser;
32
use rayon;
43
use regex::Regex;
54
use termcolor::StandardStream;
65

76
use std::default::Default;
7+
use std::io::{stderr, stdout};
88
use std::path::PathBuf;
99
use std::process::{Command, Output};
1010
use std::sync::mpsc::channel;
@@ -88,8 +88,8 @@ fn main() {
8888
// manually drop tx so the receiver ends
8989
drop(tx);
9090

91-
let stdout = StandardStream::stdout(output::color_choice(&cli.color, &atty::Stream::Stdout));
92-
let stderr = StandardStream::stderr(output::color_choice(&cli.color, &atty::Stream::Stderr));
91+
let stdout = StandardStream::stdout(output::color_choice(&cli.color, &stdout()));
92+
let stderr = StandardStream::stderr(output::color_choice(&cli.color, &stderr()));
9393
{
9494
let mut stdout_l = stdout.lock();
9595
let mut stderr_l = stderr.lock();

src/output.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use atty;
1+
use is_terminal::IsTerminal;
22
use termcolor::{Color, ColorChoice, ColorSpec, WriteColor};
33

44
use std::io::{self, Write};
55

66
use crate::cli::ColorMode;
77
use crate::GitResult;
88

9-
pub fn color_choice(color_mode: &ColorMode, stream: &atty::Stream) -> ColorChoice {
10-
match (color_mode, atty::is(*stream)) {
9+
pub fn color_choice(color_mode: &ColorMode, stream: &dyn IsTerminal) -> ColorChoice {
10+
match (color_mode, stream.is_terminal()) {
1111
(ColorMode::Always, _) => ColorChoice::Always,
1212
(ColorMode::Auto, true) => ColorChoice::Auto,
1313
(ColorMode::Auto, false) => ColorChoice::Never,

0 commit comments

Comments
 (0)