Skip to content

Commit

Permalink
code group
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Dec 12, 2024
1 parent 3503311 commit 8b8e6ea
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions docs/tasks/toml-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ cargo clippy
"""
```

Here are some examples of using `python` and `deno`:
By using `shell` or `shebang`, you can run scripts in different languages:

```toml
::: code-group

```toml [python]
[tools]
python = 'latest'

Expand All @@ -190,11 +192,37 @@ for i in range(10):
"""
```

```toml
```toml [node]
[tools]
node = 'lts'

[tasks.node_task]
shell = 'node -e'
run = [
"console.log('First line')",
"console.log('Second line')",
]
```

```toml [bun]
[tools]
bun = 'latest'

[tasks.bun_shell]
shell = "bun -e"
run = """
// https://bun.sh/docs/runtime/shell
import { $ } from "bun";
const response = await fetch("https://example.com");
await $`cat < ${response} | wc -c`; // 1256
"""
```

```toml [deno]
[tools]
deno = 'latest'

[tasks.download_task]
[tasks.deno_task]
description = "Shows that you can use deno in a task"
shell = 'deno eval' # or use a shebang: #!/usr/bin/env -S deno run
run = """
Expand All @@ -215,12 +243,23 @@ async function download() {
}
await download();
"""
# ❯ mise run download_task
# ❯ mise run deno_task
# [download_task] $ import ProgressBar from "jsr:@deno-library/progress";
# Start download? [y/N] y
# downloading: ...
```

```toml [ruby]
[tools]
ruby = 'latest'

[tasks.ruby_task]
shell = 'ruby -e'
run = "puts 'Hello, world!'"
```

:::

## Windows

You can specify an alternate command to run on Windows by using the `run_windows` key:
Expand Down

0 comments on commit 8b8e6ea

Please sign in to comment.