Skip to content

Commit

Permalink
Merge pull request #12 from jonas-schievink/fix-cargo-config-search
Browse files Browse the repository at this point in the history
Fix search for Cargo configuration
  • Loading branch information
japaric authored Sep 22, 2021
2 parents 334832d + 17924e0 commit 5889a7e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ impl Project {
// parse .cargo/config
let mut target = None;
let mut target_dir = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from);
if let Some(path) = search(root, &cargo_config).map(|path| path.join(cargo_config)).or_else(|| {
search(root, &cargo_config_toml).map(|path| path.join(cargo_config_toml))
if let Some(path) = path.ancestors().find_map(|dir| {
let path = dir.join(&cargo_config);
if path.exists() {
return Some(path);
}

let path = dir.join(&cargo_config_toml);
if path.exists() {
return Some(path);
}

None
}) {
let config: Config = parse(&path)?;

Expand Down

0 comments on commit 5889a7e

Please sign in to comment.