Skip to content

Commit

Permalink
fix(task): script tasks don't pick up alias from comments (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele committed Mar 24, 2024
1 parent 17620f9 commit 7e9b4b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .mise/tasks/lint-fix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# mise aliases=["lint:fix"]
# mise alias=["lint:fix"]
set -euxo pipefail

scripts=("$PWD"/scripts/*.sh "$PWD"/e2e/{test_,run_}* "$PWD"/e2e/*.sh)
Expand Down
16 changes: 16 additions & 0 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ impl Task {

let task = Task {
hide: !file::is_executable(path) || p.parse_bool("hide").unwrap_or_default(),
aliases: p
.parse_array("alias")?
.unwrap_or(vec![p.parse_str("alias")?.unwrap_or_default()]),
description: p.parse_str("description")?.unwrap_or_default(),
sources: p.parse_array("sources")?.unwrap_or_default(),
outputs: p.parse_array("outputs")?.unwrap_or_default(),
Expand Down Expand Up @@ -371,8 +374,21 @@ where
mod tests {
use std::path::Path;

use crate::task::Task;

use super::{config_root, name_from_path};

#[test]
fn test_from_path() {
let test_cases = [(".mise/tasks/filetask", "filetask", vec!["ft"])];

for (path, name, aliases) in test_cases {
let t = Task::from_path(Path::new(path)).unwrap();
assert_eq!(t.name, name);
assert_eq!(t.aliases, aliases);
}
}

#[test]
fn test_name_from_path() {
let test_cases = [
Expand Down
1 change: 1 addition & 0 deletions test/cwd/.mise/tasks/filetask
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# mise alias=["ft"]
# mise description="This is a test build script"
# mise depends=["lint", "test"]
# mise sources=[".test-tool-versions"]
Expand Down

0 comments on commit 7e9b4b7

Please sign in to comment.