Repository: sharkdp/fd
Pull request #1192 (2022-12-01 06:39:24)

Use nu-ansi-term instead of ansi-term
Because ansi-term is no longer maintained.

Relates-To: #1188


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index ed8b4b3..862ffe9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -20,15 +20,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "ansi_term"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
-dependencies = [
- "winapi",
-]
-
 [[package]]
 name = "anyhow"
 version = "1.0.66"
@@ -306,20 +297,10 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "fastrand"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
-dependencies = [
- "instant",
-]
-
 [[package]]
 name = "fd-find"
 version = "8.5.3"
 dependencies = [
- "ansi_term",
  "anyhow",
  "argmax",
  "atty",
@@ -340,11 +321,12 @@ dependencies = [
  "lscolors",
  "nix 0.24.2",
  "normpath",
+ "nu-ansi-term",
  "num_cpus",
  "once_cell",
  "regex",
  "regex-syntax",
- "tempfile",
+ "tempdir",
  "test-case",
  "users",
  "version_check",
@@ -374,6 +356,12 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
 
+[[package]]
+name = "fuchsia-cprng"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
+
 [[package]]
 name = "getrandom"
 version = "0.2.8"
@@ -461,15 +449,6 @@ dependencies = [
  "winapi-util",
 ]
 
-[[package]]
-name = "instant"
-version = "0.1.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
-dependencies = [
- "cfg-if",
-]
-
 [[package]]
 name = "io-lifetimes"
 version = "0.7.4"
@@ -544,11 +523,11 @@ dependencies = [
 
 [[package]]
 name = "lscolors"
-version = "0.12.0"
+version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "074bff749d092e2e818fe954952102f88e21f67fc69f4d350621aab15a1810f1"
+checksum = "c2dedc85d67baf5327114fad78ab9418f8893b1121c17d5538dd11005ad1ddf2"
 dependencies = [
- "ansi_term",
+ "nu-ansi-term",
 ]
 
 [[package]]
@@ -589,6 +568,16 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "nu-ansi-term"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
+dependencies = [
+ "overload",
+ "winapi",
+]
+
 [[package]]
 name = "num-integer"
 version = "0.1.45"
@@ -630,6 +619,12 @@ version = "6.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
 
+[[package]]
+name = "overload"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
+
 [[package]]
 name = "proc-macro-error"
 version = "1.0.4"
@@ -672,6 +667,43 @@ dependencies = [
  "proc-macro2",
 ]
 
+[[package]]
+name = "rand"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
+dependencies = [
+ "fuchsia-cprng",
+ "libc",
+ "rand_core 0.3.1",
+ "rdrand",
+ "winapi",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
+dependencies = [
+ "rand_core 0.4.2",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
+
+[[package]]
+name = "rdrand"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
+dependencies = [
+ "rand_core 0.3.1",
+]
+
 [[package]]
 name = "redox_syscall"
 version = "0.2.16"
@@ -765,17 +797,13 @@ dependencies = [
 ]
 
 [[package]]
-name = "tempfile"
-version = "3.3.0"
+name = "tempdir"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
+checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
 dependencies = [
- "cfg-if",
- "fastrand",
- "libc",
- "redox_syscall",
+ "rand",
  "remove_dir_all",
- "winapi",
 ]
 
 [[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 7e0f560..d59b606 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ path = "src/main.rs"
 version_check = "0.9"
 
 [dependencies]
-ansi_term = "0.12"
+nu-ansi-term = "0.46"
 argmax = "0.3.1"
 atty = "0.2"
 ignore = "0.4.3"
@@ -42,7 +42,6 @@ regex = "1.6.0"
 regex-syntax = "0.6"
 ctrlc = "3.2"
 humantime = "2.1"
-lscolors = "0.12"
 globset = "0.4"
 anyhow = "1.0"
 dirs-next = "2.0"
@@ -57,6 +56,11 @@ faccess = "0.2.4"
 version = "4.0.22"
 features = ["suggestions", "color", "wrap_help", "cargo", "unstable-grouped", "derive"]
 
+[dependencies.lscolors]
+version = "0.13"
+default-features = false
+features = ["nu-ansi-term"]
+
 [target.'cfg(unix)'.dependencies]
 users = "0.11.0"
 nix = { version = "0.24.2", default-features = false, features = ["signal"] }
@@ -72,7 +76,7 @@ jemallocator = {version = "0.5.0", optional = true}
 
 [dev-dependencies]
 diff = "0.1"
-tempfile = "3.3"
+tempdir = "0.3"
 filetime = "0.2"
 test-case = "2.2"
 
diff --git a/src/main.rs b/src/main.rs
index ec677cc..1a95163 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -212,7 +212,7 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
 
     #[cfg(windows)]
     let ansi_colors_support =
-        ansi_term::enable_ansi_support().is_ok() || std::env::var_os("TERM").is_some();
+        nu_ansi_term::enable_ansi_support().is_ok() || std::env::var_os("TERM").is_some();
     #[cfg(not(windows))]
     let ansi_colors_support = true;
 
diff --git a/src/output.rs b/src/output.rs
index e75bddd..e33a89d 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -46,7 +46,7 @@ fn print_trailing_slash<W: Write>(
             stdout,
             "{}",
             style
-                .map(Style::to_ansi_term_style)
+                .map(Style::to_nu_ansi_term_style)
                 .unwrap_or_default()
                 .paint(&config.actual_path_separator)
         )?;
@@ -85,14 +85,14 @@ fn print_entry_colorized<W: Write>(
 
         let style = ls_colors
             .style_for_indicator(Indicator::Directory)
-            .map(Style::to_ansi_term_style)
+            .map(Style::to_nu_ansi_term_style)
             .unwrap_or_default();
         write!(stdout, "{}", style.paint(parent_str))?;
     }
 
     let style = entry
         .style(ls_colors)
-        .map(Style::to_ansi_term_style)
+        .map(Style::to_nu_ansi_term_style)
         .unwrap_or_default();
     write!(stdout, "{}", style.paint(&path_str[offset..]))?;
 


Test patch:
diff --git a/tests/testenv/mod.rs b/tests/testenv/mod.rs
index d4bfad2..f827e78 100644
--- a/tests/testenv/mod.rs
+++ b/tests/testenv/mod.rs
@@ -8,7 +8,7 @@ use std::os::windows;
 use std::path::{Path, PathBuf};
 use std::process;
 
-use tempfile::TempDir;
+use tempdir::TempDir;
 
 /// Environment for the integration tests.
 pub struct TestEnv {
@@ -27,7 +27,7 @@ fn create_working_directory(
     directories: &[&'static str],
     files: &[&'static str],
 ) -> Result<TempDir, io::Error> {
-    let temp_dir = tempfile::Builder::new().prefix("fd-tests").tempdir()?;
+    let temp_dir = TempDir::new("fd-tests")?;
 
     {
         let root = temp_dir.path();
@@ -169,9 +169,7 @@ impl TestEnv {
         let root = self.test_root();
         let broken_symlink_link = root.join(link_path);
         {
-            let temp_target_dir = tempfile::Builder::new()
-                .prefix("fd-tests-broken-symlink")
-                .tempdir()?;
+            let temp_target_dir = TempDir::new("fd-tests-broken-symlink")?;
             let broken_symlink_target = temp_target_dir.path().join("broken_symlink_target");
             fs::File::create(&broken_symlink_target)?;
             #[cfg(unix)]