mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
chore: changelog for #2151
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
- Wildcards can now
|
||||
[match multiple tasks](https://taskfile.dev/usage/#wildcard-arguments) (#2072,
|
||||
#2121 by @pd93).
|
||||
- Added the ability to
|
||||
[loop over the files specified by the `generates` keyword](https://taskfile.dev/usage/#looping-over-your-tasks-sources-or-generated-files).
|
||||
This works the same way as looping over sources (#2151 by @sedyh).
|
||||
- Added the ability to resolve variables when defining an include variable
|
||||
(#2108, #2113 @pd93).
|
||||
- The default taskfile (output when using the `--init` flag) is now an embedded
|
||||
|
@@ -31,13 +31,8 @@ some of the examples below for some inspiration.
|
||||
No more comparing strings to "true" or "false". Now you can use actual boolean
|
||||
values in your templates:
|
||||
|
||||
<Tabs defaultValue="2"
|
||||
values={[
|
||||
{label: 'Before', value: '1'},
|
||||
{label: 'After', value: '2'}
|
||||
]}>
|
||||
|
||||
<TabItem value="1">
|
||||
<Tabs defaultValue="2">
|
||||
<TabItem value="1" label="Before">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -51,7 +46,7 @@ tasks:
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
<TabItem value="2" label="After">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -64,7 +59,8 @@ tasks:
|
||||
- '{{if .BOOL}}echo foo{{end}}' # <-- No need to compare to "true"
|
||||
```
|
||||
|
||||
</TabItem></Tabs>
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Arithmetic
|
||||
|
||||
@@ -114,13 +110,8 @@ to specify the delimiter. However, we have now added support for looping over
|
||||
"collection-type" variables using the `for` keyword, so now you are able to loop
|
||||
over list variables directly:
|
||||
|
||||
<Tabs defaultValue="2"
|
||||
values={[
|
||||
{label: 'Before', value: '1'},
|
||||
{label: 'After', value: '2'}
|
||||
]}>
|
||||
|
||||
<TabItem value="1">
|
||||
<Tabs defaultValue="2">
|
||||
<TabItem value="1" label="Before">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -137,7 +128,7 @@ tasks:
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
<TabItem value="2" label="After">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -152,7 +143,8 @@ tasks:
|
||||
cmd: echo {{.ITEM}}
|
||||
```
|
||||
|
||||
</TabItem></Tabs>
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## What about maps?
|
||||
|
||||
|
@@ -309,45 +309,38 @@ You can flatten the included Taskfile tasks into the main Taskfile by using the
|
||||
It means that the included Taskfile tasks will be available without the namespace.
|
||||
|
||||
|
||||
<Tabs defaultValue="1"
|
||||
values={[
|
||||
{label: 'Taskfile.yml', value: '1'},
|
||||
{label: 'Included.yml', value: '2'}
|
||||
]}>
|
||||
<Tabs defaultValue="1">
|
||||
<TabItem value="1" label="Taskfile.yml">
|
||||
|
||||
<TabItem value="1">
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
includes:
|
||||
includes:
|
||||
lib:
|
||||
taskfile: ./Included.yml
|
||||
flatten: true
|
||||
|
||||
tasks:
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Greet"
|
||||
- task: foo
|
||||
```
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2" label="Included.yml">
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
tasks:
|
||||
foo:
|
||||
cmds:
|
||||
- echo "Foo"
|
||||
```
|
||||
|
||||
|
||||
</TabItem></Tabs>
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
If you run `task -a` it will print :
|
||||
|
||||
@@ -368,43 +361,37 @@ Foo
|
||||
|
||||
If multiple tasks have the same name, an error will be thrown:
|
||||
|
||||
<Tabs defaultValue="1"
|
||||
values={[
|
||||
{label: 'Taskfile.yml', value: '1'},
|
||||
{label: 'Included.yml', value: '2'}
|
||||
]}>
|
||||
<Tabs defaultValue="1">
|
||||
<TabItem value="1" label="Taskfile.yml">
|
||||
|
||||
<TabItem value="1">
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
includes:
|
||||
```yaml
|
||||
version: '3'
|
||||
includes:
|
||||
lib:
|
||||
taskfile: ./Included.yml
|
||||
flatten: true
|
||||
|
||||
tasks:
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Greet"
|
||||
- task: foo
|
||||
```
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2" label="Included.yml">
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Foo"
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
</TabItem></Tabs>
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
If you run `task -a` it will print:
|
||||
```text
|
||||
@@ -420,35 +407,29 @@ You can do this by using the [`excludes` option](#exclude-tasks-from-being-inclu
|
||||
|
||||
You can exclude tasks from being included by using the `excludes` option. This option takes the list of tasks to be excluded from this include.
|
||||
|
||||
<Tabs defaultValue="1"
|
||||
values={[
|
||||
{label: 'Taskfile.yml', value: '1'},
|
||||
{label: 'Included.yml', value: '2'}
|
||||
]}>
|
||||
<Tabs defaultValue="1">
|
||||
<TabItem value="1" label="Taskfile.yml">
|
||||
|
||||
<TabItem value="1">
|
||||
```yaml
|
||||
version: '3'
|
||||
```yaml
|
||||
version: '3'
|
||||
includes:
|
||||
included:
|
||||
taskfile: ./Included.yml
|
||||
excludes: [foo]
|
||||
```
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2" label="Included.yml">
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
tasks:
|
||||
foo: echo "Foo"
|
||||
bar: echo "Bar"
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
</TabItem></Tabs>
|
||||
</TabItem></Tabs>
|
||||
|
||||
`task included:foo` will throw an error because the `foo` task is excluded but `task included:bar` will work and display `Bar`.
|
||||
|
||||
@@ -1255,13 +1236,8 @@ a value from one task to another. However, the templating engine is only able to
|
||||
output strings. If you want to pass something other than a string to another
|
||||
task then you will need to use a reference (`ref`) instead.
|
||||
|
||||
<Tabs defaultValue="2"
|
||||
values={[
|
||||
{ label: 'Templating Engine', value: '1' },
|
||||
{ label: 'Reference', value: '2' }
|
||||
]}>
|
||||
|
||||
<TabItem value="1">
|
||||
<Tabs defaultValue="2">
|
||||
<TabItem value="1" label="Templating Engine">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -1280,7 +1256,7 @@ tasks:
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
<TabItem value="2" label="Reference">
|
||||
|
||||
```yaml
|
||||
version: 3
|
||||
@@ -1299,7 +1275,8 @@ tasks:
|
||||
- 'echo {{index .FOO 0}}' # <-- FOO is still a map so the task outputs 'A' as expected
|
||||
```
|
||||
|
||||
</TabItem></Tabs>
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
This also works the same way when calling `deps` and when defining
|
||||
a variable and can be used in any combination:
|
||||
@@ -1441,9 +1418,13 @@ tasks:
|
||||
cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
|
||||
```
|
||||
|
||||
### Looping over your task's sources
|
||||
### Looping over your task's sources or generated files
|
||||
|
||||
You are also able to loop over the sources of your task:
|
||||
You are also able to loop over the sources of your task or the files it
|
||||
generates:
|
||||
|
||||
<Tabs defaultValue="1" groupId="sources-generates">
|
||||
<TabItem value="1" label="Sources">
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
@@ -1458,14 +1439,37 @@ tasks:
|
||||
cmd: cat {{ .ITEM }}
|
||||
```
|
||||
|
||||
This will also work if you use globbing syntax in your sources. For example, if
|
||||
you specify a source for `*.txt`, the loop will iterate over all files that
|
||||
match that glob.
|
||||
</TabItem>
|
||||
<TabItem value="2" label="Generates">
|
||||
|
||||
Source paths will always be returned as paths relative to the task directory. If
|
||||
you need to convert this to an absolute path, you can use the built-in
|
||||
`joinPath` function. There are some [special variables](/reference/templating/#special-variables)
|
||||
that you may find useful for this.
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
default:
|
||||
generates:
|
||||
- foo.txt
|
||||
- bar.txt
|
||||
cmds:
|
||||
- for: generates
|
||||
cmd: cat {{ .ITEM }}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
This will also work if you use globbing syntax in `sources` or `generates`. For
|
||||
example, if you specify a source for `*.txt`, the loop will iterate over all
|
||||
files that match that glob.
|
||||
|
||||
Paths will always be returned as paths relative to the task directory. If you
|
||||
need to convert this to an absolute path, you can use the built-in `joinPath`
|
||||
function. There are some [special
|
||||
variables](/reference/templating/#special-variables) that you may find useful
|
||||
for this.
|
||||
|
||||
<Tabs defaultValue="1" groupId="sources-generates">
|
||||
<TabItem value="1" label="Sources">
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
@@ -1483,31 +1487,8 @@ tasks:
|
||||
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
||||
```
|
||||
|
||||
### Looping over your task's generates
|
||||
|
||||
Similar to sources, you can also loop over the generates of your task:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
default:
|
||||
generates:
|
||||
- foo.txt
|
||||
- bar.txt
|
||||
cmds:
|
||||
- for: generates
|
||||
cmd: cat {{ .ITEM }}
|
||||
```
|
||||
|
||||
This will also work if you use globbing syntax in your generates. For example, if
|
||||
you specify a generate for `*.txt`, the loop will iterate over all files that
|
||||
match that glob.
|
||||
|
||||
Generate paths will always be returned as paths relative to the task directory. If
|
||||
you need to convert this to an absolute path, you can use the built-in
|
||||
`joinPath` function. There are some [special variables](/reference/templating/#special-variables)
|
||||
that you may find useful for this.
|
||||
</TabItem>
|
||||
<TabItem value="2" label="Generates">
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
@@ -1525,6 +1506,9 @@ tasks:
|
||||
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Looping over variables
|
||||
|
||||
To loop over the contents of a variable, you simply need to specify the variable
|
||||
|
Reference in New Issue
Block a user