Skip to content

Commit 911a973

Browse files
authoredAug 26, 2023
Merge PR #47 -- Avoid atty crate
Bump MSRV to 1.63 Supersedes my PR #45
2 parents 8c90668 + 20871c9 commit 911a973

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed
 

‎.github/workflows/test.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
strategy:
2929
fail-fast: false # Even if one job fails we still want to see the other ones
3030
matrix:
31-
# 1.53 is MSRV. Keep in sync with Cargo.toml
32-
rust: [1.53, stable, nightly]
31+
# 1.63 is MSRV. Keep in sync with Cargo.toml
32+
rust: [1.63, stable, nightly]
3333
# NOTE: Features to test must be specified manually. They are applied to all versions seperately.
3434
#
3535
# This has the advantage of being more flexibile and thorough
@@ -47,5 +47,7 @@ jobs:
4747
# NOTE: We only run `cargo test`. No need for a seperate `cargo check`
4848
- name: Test
4949
run: |
50-
cargo test --verbose --features "${{ matrix.features }}"
50+
# Pin a time version with a compatible MSRV
51+
cargo update --package time --precise 0.3.20
52+
cargo test --locked --verbose --features "${{ matrix.features }}"
5153

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
<!-- next-url -->
88
## [Unreleased](https://github.com/slog-rs/term/compare/v2.8.1...HEAD) - ReleaseDate
9+
* Switch from `atty` to `is_terminal`
10+
* Avoids [RUSTSEC-2021-0145](https://rustsec.org/advisories/RUSTSEC-2021-0145)
11+
* BREAKING: Bump MSRV to 1.63
912

1013
## 2.9.0 - 2022-02-20
1114
### Changed

‎Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ edition = "2018"
1717
#
1818
# The first version of Cargo that supports this field was in Rust 1.56.0.
1919
# In older releases, the field will be ignored, and Cargo will display a warning.
20-
rust-version = "1.53"
20+
rust-version = "1.63"
2121

2222
[features]
2323
nested-values = ["erased-serde", "serde", "serde_json", "slog/nested-values"]
2424

2525
[dependencies]
2626
slog = "2"
27-
atty = "0.2"
27+
is-terminal = "0.4"
2828
time = { version = "0.3", default-features = false, features = ["macros", "formatting"] }
2929
thread_local = "1"
3030
term = "0.7"

‎src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ use std::io::Write as IoWrite;
9393
use std::panic::{RefUnwindSafe, UnwindSafe};
9494
use std::result;
9595
use std::{fmt, io, mem, sync};
96+
97+
// TODO: Should probably look into `std::io::IsTerminal` if/when that becomes stable
98+
// See tracking issue rust-lang/rust#98070
99+
//
100+
// This should really be an issue we file on the `is-terminal` crate
101+
use is_terminal::IsTerminal;
96102
// }}}
97103

98104
// {{{ Decorator
@@ -1332,8 +1338,8 @@ enum AnyTerminal {
13321338
impl AnyTerminal {
13331339
fn should_use_color(&self) -> bool {
13341340
match *self {
1335-
AnyTerminal::Stdout { .. } => atty::is(atty::Stream::Stdout),
1336-
AnyTerminal::Stderr { .. } => atty::is(atty::Stream::Stderr),
1341+
AnyTerminal::Stdout { .. } => std::io::stdout().is_terminal(),
1342+
AnyTerminal::Stderr { .. } => std::io::stderr().is_terminal(),
13371343
AnyTerminal::FallbackStdout => false,
13381344
AnyTerminal::FallbackStderr => false,
13391345
}

0 commit comments

Comments
 (0)