mirror of
https://github.com/go-task/task.git
synced 2026-06-29 23:55:18 +00:00
feat: can exclude task from being included (#1859)
This commit is contained in:
@@ -393,6 +393,8 @@ You can run `task foo` directly without the namespace.
|
||||
You can also reference the task in other tasks without the namespace. So if you run `task greet` it will run `greet` and `foo` tasks and the output will be :
|
||||
|
||||
```text
|
||||
Greet
|
||||
Foo
|
||||
```
|
||||
|
||||
If multiple tasks have the same name, an error will be thrown:
|
||||
@@ -409,14 +411,14 @@ If multiple tasks have the same name, an error will be thrown:
|
||||
version: '3'
|
||||
includes:
|
||||
lib:
|
||||
taskfile: ./Included.yml
|
||||
flatten: true
|
||||
taskfile: ./Included.yml
|
||||
flatten: true
|
||||
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Greet"
|
||||
- task: foo
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Greet"
|
||||
- task: foo
|
||||
```
|
||||
|
||||
|
||||
@@ -427,9 +429,9 @@ If multiple tasks have the same name, an error will be thrown:
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Foo"
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Foo"
|
||||
```
|
||||
|
||||
|
||||
@@ -438,12 +440,50 @@ If multiple tasks have the same name, an error will be thrown:
|
||||
If you run `task -a` it will print:
|
||||
```text
|
||||
task: Found multiple tasks (greet) included by "lib"
|
||||
|
||||
```
|
||||
|
||||
If you the included Taskfile has a task with the same name as a task in the main Taskfile,
|
||||
you may want to exclude it from the flattened tasks.
|
||||
|
||||
You can do this by using the [`excludes` option](#exclude-tasks-from-being-included).
|
||||
|
||||
### Exclude tasks from being included
|
||||
|
||||
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'}
|
||||
]}>
|
||||
|
||||
<TabItem value="1">
|
||||
```yaml
|
||||
version: '3'
|
||||
includes:
|
||||
included:
|
||||
taskfile: ./Included.yml
|
||||
excludes: [foo]
|
||||
```
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="2">
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
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`.
|
||||
|
||||
It's compatible with the `flatten` option.
|
||||
|
||||
### Vars of included Taskfiles
|
||||
|
||||
|
||||
Reference in New Issue
Block a user