Skip to content

Commit

Permalink
fix: group prefix not applied for script tasks (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele authored Jun 10, 2024
1 parent 9ae8952 commit 3b038c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use super::args::ToolArg;
/// outputs = ["dist/**/*.js"]
///
/// Alternatively, tasks can be defined as standalone scripts.
/// These must be located in the `.mise/tasks` directory.
/// These must be located in the `.mise/tasks`, `mise/tasks` or `.config/mise/tasks` directory.
/// The name of the script will be the name of the tasks.
///
/// $ cat .mise/tasks/build<<EOF
Expand Down
6 changes: 6 additions & 0 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ fn name_from_path(root: impl AsRef<Path>, path: impl AsRef<Path>) -> Result<Stri
.strip_prefix(root)
.map(|p| match p {
p if p.starts_with(".mise/tasks") => p.strip_prefix(".mise/tasks"),
p if p.starts_with("mise/tasks") => p.strip_prefix("mise/tasks"),
p if p.starts_with(".config/mise/tasks") => p.strip_prefix(".config/mise/tasks"),
_ => Ok(p),
})??
Expand Down Expand Up @@ -338,6 +339,10 @@ fn config_root(config_source: &impl AsRef<Path>) -> Option<&Path> {
if ancestor.ends_with(".config/mise/tasks") {
return ancestor.parent()?.parent()?.parent();
}

if ancestor.ends_with("mise/tasks") {
return ancestor.parent()?.parent();
}
}

config_source.as_ref().parent()
Expand Down Expand Up @@ -424,6 +429,7 @@ mod tests {
("/base", Some(Path::new("/"))),
("/base/.mise/tasks", Some(Path::new("/base"))),
("/base/.config/mise/tasks", Some(Path::new("/base"))),
("/base/mise/tasks", Some(Path::new("/base"))),
];

for (src, expected) in test_cases {
Expand Down

0 comments on commit 3b038c7

Please sign in to comment.