Skip to content

Commit

Permalink
fix(task): tasks not working in system config (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele authored Mar 20, 2024
1 parent 4f13c63 commit d5df98c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl Config {
.into_iter()
.flatten()
.chain(self.load_global_tasks()?)
.chain(self.load_system_tasks()?)
.rev()
.inspect(|t| trace!("loading task {t} from {}", display_path(&t.config_source)))
.map(|t| (t.name.clone(), t))
Expand Down Expand Up @@ -252,21 +253,32 @@ impl Config {
fn load_global_tasks(&self) -> Result<Vec<Task>> {
let cf = self.config_files.get(&*env::MISE_GLOBAL_CONFIG_FILE);
Ok(self
.load_global_config_tasks(&cf)
.load_config_tasks(&cf)
.into_iter()
.chain(self.load_global_file_tasks(&cf))
.chain(self.load_file_tasks(&cf))
.collect())
}

fn load_system_tasks(&self) -> Result<Vec<Task>> {
let cf = self.config_files.get(&dirs::SYSTEM.join("config.toml"));
Ok(self
.load_config_tasks(&cf)
.into_iter()
.chain(self.load_file_tasks(&cf))
.collect())
}

#[allow(clippy::borrowed_box)]
fn load_global_config_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>) -> Vec<Task> {
fn load_config_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>) -> Vec<Task> {
cf.map(|cf| cf.tasks())
.unwrap_or_default()
.into_iter()
.cloned()
.collect()
}

#[allow(clippy::borrowed_box)]
fn load_global_file_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>) -> Vec<Task> {
fn load_file_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>) -> Vec<Task> {
let includes = match cf {
Some(cf) => cf
.task_config()
Expand Down

0 comments on commit d5df98c

Please sign in to comment.