Skip to content

Commit

Permalink
Merge pull request #17 from kenchou/main
Browse files Browse the repository at this point in the history
detect config.toml
  • Loading branch information
wtklbm committed Nov 22, 2023
2 parents cb4f0ce + 67e7831 commit dc102c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub const DOT_CARGO: &str = ".cargo";
/// `${CARGO_HOME}/.cargo` 目录下的 `config` 文件
pub const CONFIG: &str = "config";

/// `${CARGO_HOME}/.cargo` 目录下的 `config` 文件
pub const CONFIG_TOML: &str = "config.toml";

/// `dl`
pub const DL: &str = "dl";

Expand Down
5 changes: 4 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::{

use ureq::Error;

use crate::constants::{CARGO_CONFIG_PATH, CARGO_HOME, CONFIG, DOT_CARGO, UNC_PREFIX};
use crate::constants::{CARGO_CONFIG_PATH, CARGO_HOME, CONFIG, CONFIG_TOML, DOT_CARGO, UNC_PREFIX};

pub fn home_dir() -> PathBuf {
env::home_dir().unwrap()
Expand All @@ -35,6 +35,9 @@ pub fn cargo_home() -> PathBuf {
pub fn cargo_config_path() -> PathBuf {
let mut c = cargo_home();
c.push(CONFIG);
if !c.exists() {
c.set_file_name(CONFIG_TOML);
}

c
}
Expand Down

0 comments on commit dc102c4

Please sign in to comment.