Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

docs(tasks): updated task docs for pattern matching and grouping #30

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions tasks/running-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ To just print stdout/stderr directly, use `--interleave`, the `task_output` sett
Stdin is not read by default. To enable this, set `raw = true` on the task that needs it. This will prevent
it running in parallel with any other task-a RWMutex will get a write lock in this case.

There is partial support for wildcards, for example, this makes a "lint" task that runs everything that begins with "lint:".

```toml
[tasks."lint:eslint"] # using a ":" means we need to add quotes
run = "eslint ."
[tasks."lint:prettier"]
run = "prettier --check ."
[tasks.lint]
depends = ["lint:*"]
```

::: info
As of this writing these wildcards only function at the right side and only work for dependencies.
It should be possible to also run `mise run lint:*` but that is not yet implemented.
:::

Extra arguments will be passed to the task, for example, if we want to run in release mode:

```bash
Expand All @@ -49,6 +33,44 @@ mise will run the task named "default" if no task is specified—and you've crea
mise run
```

## Task Grouping

Tasks can be grouped semantically by using name prefixes separated with `:`s.
For example all testing related tasks may begin with `test:`. Nested grouping
can also be used to further refine groups and simplify pattern matching.
For example running `mise run test:**:local` will match`test:units:local`,
`test:integration:local` and `test:e2e:happy:local`
(See [Wildcards](#wildcards) for more information).

## Wildcards

Glob style wildcards are supported when running tasks or specifying tasks
dependencies.

Available Wildcard Patterns:

- `?` matches any single character
- `*` matches 0 or more characters
- `**` matches 0 or more groups
- `{glob1,glob2,...}` matches any of the comma-separated glob patterns
- `[ab,...]` matches any of the characters or ranges `[a-z]`
- `[!ab,...]` matches any character not in the character set

### Examples

`mise run generate:{completions,docs:*}`

And with dependencies:

```toml
[tasks."lint:eslint"] # using a ":" means we need to add quotes
run = "eslint ."
[tasks."lint:prettier"]
run = "prettier --check ."
[tasks.lint]
depends = ["lint:*"]
```

## Running on file changes

It's often handy to only execute a task if the files it uses changes. For example, we might only want
Expand Down
30 changes: 30 additions & 0 deletions tasks/script-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,33 @@ This script can be edited with by running `mise task edit build` (using $EDITOR)
These are convenient for quickly making new scripts. Having the code in a bash file and not TOML helps make it work
better in editors since they can do syntax highlighting and linting more easily. They also still work great for non-mise users—though
of course they'll need to find a different way to install their dev tools the tasks might use.
:::

## Task Grouping

Script tasks in `.mise/tasks` or `.config/mise/tasks` can be grouped into
sub-directories which will automatically apply prefixes to their names
when loaded.

### Example

With a folder structure like below:

```text
.mise
└── tasks
├── build
└── test
├── integration
└── units
```

Running `mise tasks` will give the below output:

```text
$ mise tasks
Name Description Source
build .../.mise/tasks/build
test:integration .../.mise/tasks/test/integration
test:units .../.mise/tasks/test/units
```