Skip to content

Commit

Permalink
replace dirs with etcetera
Browse files Browse the repository at this point in the history
  • Loading branch information
heygarrett committed Jun 6, 2024
1 parent c97996f commit 7a52bd2
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 42 deletions.
142 changes: 104 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cargo_metadata = "0.18"
clap = { version = "4.4.2", features = ["derive"] }
clap-cargo = "0.12.0"
diff = "0.1"
dirs = "5.0"
etcetera = "0.8.0"
getopts = "0.2"
ignore = "0.4"
itertools = "0.12"
Expand Down
7 changes: 4 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::io::{Error, ErrorKind, Read};
use std::path::{Path, PathBuf};
use std::{env, fs};

use etcetera::BaseStrategy;
use thiserror::Error;

use crate::config::config_type::ConfigType;
Expand Down Expand Up @@ -281,15 +282,15 @@ impl Config {
}

// If nothing was found, check in the home directory.
if let Some(home_dir) = dirs::home_dir() {
if let Ok(home_dir) = etcetera::home_dir() {
if let Some(path) = get_toml_path(&home_dir)? {
return Ok(Some(path));
}
}

// If none was found there either, check in the user's configuration directory.
if let Some(mut config_dir) = dirs::config_dir() {
config_dir.push("rustfmt");
if let Ok(strategy) = etcetera::choose_base_strategy() {
let config_dir = strategy.config_dir().join("rustfmt");
if let Some(path) = get_toml_path(&config_dir)? {
return Ok(Some(path));
}
Expand Down

0 comments on commit 7a52bd2

Please sign in to comment.