Skip to content

Commit

Permalink
fix: path option should take precedence over global configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
roele committed Jan 28, 2025
1 parent bc1c4a0 commit 6b79a23
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,25 @@ impl Use {

fn get_config_file(&self) -> Result<Box<dyn ConfigFile>> {
let cwd = env::current_dir()?;
let path = if !env::MISE_ENV.is_empty() {
let env = env::MISE_ENV.last().unwrap();
config_file_from_dir(&cwd.join(format!("mise.{env}.toml")))
} else if self.global || env::in_home_dir() {
MISE_GLOBAL_CONFIG_FILE.clone()
let path = if let Some(p) = &self.path {
let from_dir = config_file_from_dir(p).absolutize()?.to_path_buf();
if from_dir.starts_with(&cwd) {
from_dir
} else {
p.clone()
}
} else if let Some(env) = &self.env {
let p = cwd.join(format!(".mise.{env}.toml"));
if p.exists() {
p
} else {
cwd.join(format!("mise.{env}.toml"))
}
} else if let Some(p) = &self.path {
let from_dir = config_file_from_dir(p).absolutize()?.to_path_buf();
if from_dir.starts_with(&cwd) {
from_dir
} else {
p.clone()
}
} else if !env::MISE_ENV.is_empty() {
let env = env::MISE_ENV.last().unwrap();
config_file_from_dir(&cwd.join(format!("mise.{env}.toml")))
} else if self.global || env::in_home_dir() {
MISE_GLOBAL_CONFIG_FILE.clone()
} else {
config_file_from_dir(&cwd)
};
Expand Down

0 comments on commit 6b79a23

Please sign in to comment.