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
|
- Wildcards can now
|
||||||
[match multiple tasks](https://taskfile.dev/usage/#wildcard-arguments) (#2072,
|
[match multiple tasks](https://taskfile.dev/usage/#wildcard-arguments) (#2072,
|
||||||
#2121 by @pd93).
|
#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
|
- Added the ability to resolve variables when defining an include variable
|
||||||
(#2108, #2113 @pd93).
|
(#2108, #2113 @pd93).
|
||||||
- The default taskfile (output when using the `--init` flag) is now an embedded
|
- 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
|
No more comparing strings to "true" or "false". Now you can use actual boolean
|
||||||
values in your templates:
|
values in your templates:
|
||||||
|
|
||||||
<Tabs defaultValue="2"
|
<Tabs defaultValue="2">
|
||||||
values={[
|
<TabItem value="1" label="Before">
|
||||||
{label: 'Before', value: '1'},
|
|
||||||
{label: 'After', value: '2'}
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -51,7 +46,7 @@ tasks:
|
|||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="2">
|
<TabItem value="2" label="After">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -64,7 +59,8 @@ tasks:
|
|||||||
- '{{if .BOOL}}echo foo{{end}}' # <-- No need to compare to "true"
|
- '{{if .BOOL}}echo foo{{end}}' # <-- No need to compare to "true"
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem></Tabs>
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
### Arithmetic
|
### 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
|
"collection-type" variables using the `for` keyword, so now you are able to loop
|
||||||
over list variables directly:
|
over list variables directly:
|
||||||
|
|
||||||
<Tabs defaultValue="2"
|
<Tabs defaultValue="2">
|
||||||
values={[
|
<TabItem value="1" label="Before">
|
||||||
{label: 'Before', value: '1'},
|
|
||||||
{label: 'After', value: '2'}
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -137,7 +128,7 @@ tasks:
|
|||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="2">
|
<TabItem value="2" label="After">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -152,7 +143,8 @@ tasks:
|
|||||||
cmd: echo {{.ITEM}}
|
cmd: echo {{.ITEM}}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem></Tabs>
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
## What about maps?
|
## 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.
|
It means that the included Taskfile tasks will be available without the namespace.
|
||||||
|
|
||||||
|
|
||||||
<Tabs defaultValue="1"
|
<Tabs defaultValue="1">
|
||||||
values={[
|
<TabItem value="1" label="Taskfile.yml">
|
||||||
{label: 'Taskfile.yml', value: '1'},
|
|
||||||
{label: 'Included.yml', value: '2'}
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
```yaml
|
includes:
|
||||||
version: '3'
|
lib:
|
||||||
|
taskfile: ./Included.yml
|
||||||
|
flatten: true
|
||||||
|
|
||||||
includes:
|
tasks:
|
||||||
lib:
|
greet:
|
||||||
taskfile: ./Included.yml
|
cmds:
|
||||||
flatten: true
|
- echo "Greet"
|
||||||
|
- task: foo
|
||||||
|
```
|
||||||
|
|
||||||
tasks:
|
</TabItem>
|
||||||
greet:
|
<TabItem value="2" label="Included.yml">
|
||||||
cmds:
|
|
||||||
- echo "Greet"
|
|
||||||
- task: foo
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
</TabItem>
|
tasks:
|
||||||
<TabItem value="2">
|
foo:
|
||||||
|
cmds:
|
||||||
```yaml
|
- echo "Foo"
|
||||||
version: '3'
|
```
|
||||||
|
|
||||||
tasks:
|
|
||||||
foo:
|
|
||||||
cmds:
|
|
||||||
- echo "Foo"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
</TabItem></Tabs>
|
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
If you run `task -a` it will print :
|
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:
|
If multiple tasks have the same name, an error will be thrown:
|
||||||
|
|
||||||
<Tabs defaultValue="1"
|
<Tabs defaultValue="1">
|
||||||
values={[
|
<TabItem value="1" label="Taskfile.yml">
|
||||||
{label: 'Taskfile.yml', value: '1'},
|
|
||||||
{label: 'Included.yml', value: '2'}
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
includes:
|
||||||
|
lib:
|
||||||
|
taskfile: ./Included.yml
|
||||||
|
flatten: true
|
||||||
|
|
||||||
```yaml
|
tasks:
|
||||||
version: '3'
|
greet:
|
||||||
includes:
|
cmds:
|
||||||
lib:
|
- echo "Greet"
|
||||||
taskfile: ./Included.yml
|
- task: foo
|
||||||
flatten: true
|
```
|
||||||
|
|
||||||
tasks:
|
</TabItem>
|
||||||
greet:
|
<TabItem value="2" label="Included.yml">
|
||||||
cmds:
|
|
||||||
- echo "Greet"
|
|
||||||
- task: foo
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
</TabItem>
|
tasks:
|
||||||
<TabItem value="2">
|
greet:
|
||||||
|
cmds:
|
||||||
|
- echo "Foo"
|
||||||
|
```
|
||||||
|
|
||||||
```yaml
|
</TabItem>
|
||||||
version: '3'
|
</Tabs>
|
||||||
|
|
||||||
tasks:
|
|
||||||
greet:
|
|
||||||
cmds:
|
|
||||||
- echo "Foo"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
</TabItem></Tabs>
|
|
||||||
|
|
||||||
If you run `task -a` it will print:
|
If you run `task -a` it will print:
|
||||||
```text
|
```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.
|
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"
|
<Tabs defaultValue="1">
|
||||||
values={[
|
<TabItem value="1" label="Taskfile.yml">
|
||||||
{label: 'Taskfile.yml', value: '1'},
|
|
||||||
{label: 'Included.yml', value: '2'}
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
```yaml
|
||||||
```yaml
|
version: '3'
|
||||||
version: '3'
|
includes:
|
||||||
includes:
|
included:
|
||||||
included:
|
taskfile: ./Included.yml
|
||||||
taskfile: ./Included.yml
|
excludes: [foo]
|
||||||
excludes: [foo]
|
```
|
||||||
```
|
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="2" label="Included.yml">
|
||||||
|
|
||||||
</TabItem>
|
```yaml
|
||||||
<TabItem value="2">
|
version: '3'
|
||||||
|
|
||||||
```yaml
|
tasks:
|
||||||
version: '3'
|
foo: echo "Foo"
|
||||||
|
bar: echo "Bar"
|
||||||
|
```
|
||||||
|
|
||||||
tasks:
|
</TabItem></Tabs>
|
||||||
foo: echo "Foo"
|
|
||||||
bar: echo "Bar"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
</TabItem></Tabs>
|
|
||||||
|
|
||||||
`task included:foo` will throw an error because the `foo` task is excluded but `task included:bar` will work and display `Bar`.
|
`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
|
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.
|
task then you will need to use a reference (`ref`) instead.
|
||||||
|
|
||||||
<Tabs defaultValue="2"
|
<Tabs defaultValue="2">
|
||||||
values={[
|
<TabItem value="1" label="Templating Engine">
|
||||||
{ label: 'Templating Engine', value: '1' },
|
|
||||||
{ label: 'Reference', value: '2' }
|
|
||||||
]}>
|
|
||||||
|
|
||||||
<TabItem value="1">
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -1280,7 +1256,7 @@ tasks:
|
|||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="2">
|
<TabItem value="2" label="Reference">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 3
|
version: 3
|
||||||
@@ -1299,7 +1275,8 @@ tasks:
|
|||||||
- 'echo {{index .FOO 0}}' # <-- FOO is still a map so the task outputs 'A' as expected
|
- '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
|
This also works the same way when calling `deps` and when defining
|
||||||
a variable and can be used in any combination:
|
a variable and can be used in any combination:
|
||||||
@@ -1441,9 +1418,13 @@ tasks:
|
|||||||
cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
|
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
|
```yaml
|
||||||
version: '3'
|
version: '3'
|
||||||
@@ -1458,14 +1439,37 @@ tasks:
|
|||||||
cmd: cat {{ .ITEM }}
|
cmd: cat {{ .ITEM }}
|
||||||
```
|
```
|
||||||
|
|
||||||
This will also work if you use globbing syntax in your sources. For example, if
|
</TabItem>
|
||||||
you specify a source for `*.txt`, the loop will iterate over all files that
|
<TabItem value="2" label="Generates">
|
||||||
match that glob.
|
|
||||||
|
|
||||||
Source paths will always be returned as paths relative to the task directory. If
|
```yaml
|
||||||
you need to convert this to an absolute path, you can use the built-in
|
version: '3'
|
||||||
`joinPath` function. There are some [special variables](/reference/templating/#special-variables)
|
|
||||||
that you may find useful for this.
|
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
|
```yaml
|
||||||
version: '3'
|
version: '3'
|
||||||
@@ -1483,31 +1487,8 @@ tasks:
|
|||||||
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Looping over your task's generates
|
</TabItem>
|
||||||
|
<TabItem value="2" label="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.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3'
|
version: '3'
|
||||||
@@ -1525,6 +1506,9 @@ tasks:
|
|||||||
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
cmd: cat {{joinPath .MY_DIR .ITEM}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
### Looping over variables
|
### Looping over variables
|
||||||
|
|
||||||
To loop over the contents of a variable, you simply need to specify the variable
|
To loop over the contents of a variable, you simply need to specify the variable
|
||||||
|
Reference in New Issue
Block a user