Skip to content

Commit

Permalink
feat: added MISE_TASK_DISABLE_PATHS setting
Browse files Browse the repository at this point in the history
Fixes #3250
  • Loading branch information
jdx committed Nov 29, 2024
1 parent 4bbc340 commit 9c2e6e4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,6 @@ ignored = ["built", "openssl", "cfg_aliases"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }

[lints.clippy]
borrowed_box = "allow"
8 changes: 8 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@
"description": "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var.",
"type": "string"
},
"task_disable_paths": {
"default": [],
"description": "Paths that mise will not look for tasks in.",
"type": "array",
"items": {
"type": "string"
}
},
"task_output": {
"description": "Change output style when executing tasks.",
"type": "string",
Expand Down
8 changes: 8 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,14 @@ type = "Path"
optional = true
description = "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var."

[task_disable_paths]
env = "MISE_TASK_DISABLE_PATHS"
type = "ListPath"
rust_type = "BTreeSet<PathBuf>"
default = []
parse_env = "list_by_colon"
description = "Paths that mise will not look for tasks in."

[task_output]
env = "MISE_TASK_OUTPUT"
type = "String"
Expand Down
3 changes: 1 addition & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ impl Config {
.collect())
}

#[allow(clippy::borrowed_box)]
fn load_config_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>) -> Vec<Task> {
cf.map(|cf| cf.tasks())
.unwrap_or_default()
Expand All @@ -436,7 +435,6 @@ impl Config {
.collect()
}

#[allow(clippy::borrowed_box)]
fn load_file_tasks(&self, cf: &Option<&Box<dyn ConfigFile>>, config_root: &Path) -> Vec<Task> {
let includes = match cf {
Some(cf) => cf
Expand Down Expand Up @@ -475,6 +473,7 @@ impl Config {
.try_collect::<_, Vec<PathBuf>, _>()?
.into_par_iter()
.filter(|p| file::is_executable(p))
.filter(|p| !SETTINGS.task_disable_paths.iter().any(|d| p.starts_with(d)))
.map(|path| Task::from_path(&path, root, config_root))
.collect()
}
Expand Down
1 change: 0 additions & 1 deletion src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ impl Task {
}
}

#[allow(clippy::borrowed_box)]
pub fn cf<'a>(&self, config: &'a Config) -> Option<&'a Box<dyn ConfigFile>> {
config.config_files.get(&self.config_source)
}
Expand Down

0 comments on commit 9c2e6e4

Please sign in to comment.