Skip to content

Commit 6ab54b6

Browse files
committed
replace dirs with etcetera
1 parent 55a7026 commit 6ab54b6

File tree

3 files changed

+109
-42
lines changed

3 files changed

+109
-42
lines changed

Cargo.lock

Lines changed: 104 additions & 38 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
@@ -40,7 +40,7 @@ cargo_metadata = "0.18"
4040
clap = { version = "4.4.2", features = ["derive"] }
4141
clap-cargo = "0.12.0"
4242
diff = "0.1"
43-
dirs = "5.0"
43+
etcetera = "0.8.0"
4444
getopts = "0.2"
4545
ignore = "0.4"
4646
itertools = "0.12"

src/config/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::io::{Error, ErrorKind, Read};
44
use std::path::{Path, PathBuf};
55
use std::{env, fs};
66

7+
use etcetera::BaseStrategy;
78
use thiserror::Error;
89

910
use crate::config::config_type::ConfigType;
@@ -281,15 +282,15 @@ impl Config {
281282
}
282283

283284
// If nothing was found, check in the home directory.
284-
if let Some(home_dir) = dirs::home_dir() {
285+
if let Ok(home_dir) = etcetera::home_dir() {
285286
if let Some(path) = get_toml_path(&home_dir)? {
286287
return Ok(Some(path));
287288
}
288289
}
289290

290291
// If none was found there either, check in the user's configuration directory.
291-
if let Some(mut config_dir) = dirs::config_dir() {
292-
config_dir.push("rustfmt");
292+
if let Ok(strategy) = etcetera::choose_base_strategy() {
293+
let config_dir = strategy.config_dir().join("rustfmt");
293294
if let Some(path) = get_toml_path(&config_dir)? {
294295
return Ok(Some(path));
295296
}

0 commit comments

Comments
 (0)