mirror of
https://github.com/go-task/task.git
synced 2025-08-08 22:36:57 +02:00
add docs
This commit is contained in:
@@ -4,12 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/go-task/task/v3/errors"
|
||||||
"github.com/go-task/task/v3/internal/deepcopy"
|
"github.com/go-task/task/v3/internal/deepcopy"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Precondition represents a precondition necessary for a task to run
|
// Precondition represents a precondition necessary for a task to run
|
||||||
@@ -25,6 +23,12 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func NewPreconditions() *Preconditions {
|
||||||
|
return &Preconditions{
|
||||||
|
Preconditions: make([]*Precondition, 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Preconditions) DeepCopy() *Preconditions {
|
func (p *Preconditions) DeepCopy() *Preconditions {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -46,12 +50,6 @@ func (p *Precondition) DeepCopy() *Precondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPreconditions() *Preconditions {
|
|
||||||
return &Preconditions{
|
|
||||||
Preconditions: make([]*Precondition, 0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
||||||
func (p *Precondition) UnmarshalYAML(node *yaml.Node) error {
|
func (p *Precondition) UnmarshalYAML(node *yaml.Node) error {
|
||||||
switch node.Kind {
|
switch node.Kind {
|
||||||
|
@@ -1019,6 +1019,21 @@ tasks:
|
|||||||
- echo "I will not run"
|
- echo "I will not run"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
They can be defined at two levels:
|
||||||
|
|
||||||
|
- Global Level: Applies to all tasks.
|
||||||
|
- Task Level: Applies only to a specific task.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
preconditions:
|
||||||
|
- sh: 'exit 1'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
task-will-fail: echo "I will not run"
|
||||||
|
```
|
||||||
|
|
||||||
### Limiting when tasks run
|
### Limiting when tasks run
|
||||||
|
|
||||||
If a task executed by multiple `cmds` or multiple `deps` you can control when it
|
If a task executed by multiple `cmds` or multiple `deps` you can control when it
|
||||||
|
Reference in New Issue
Block a user