-
-
Notifications
You must be signed in to change notification settings - Fork 825
Expand file tree
/
Copy pathdep.go
More file actions
62 lines (54 loc) · 1.28 KB
/
dep.go
File metadata and controls
62 lines (54 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package ast
import (
"go.yaml.in/yaml/v4"
"github.com/go-task/task/v3/errors"
)
// Dep is a task dependency
type Dep struct {
Task string
For *For
Vars *Vars
Silent bool
InheritOutdated bool
}
func (d *Dep) DeepCopy() *Dep {
if d == nil {
return nil
}
return &Dep{
Task: d.Task,
For: d.For.DeepCopy(),
Vars: d.Vars.DeepCopy(),
Silent: d.Silent,
InheritOutdated: d.InheritOutdated,
}
}
func (d *Dep) UnmarshalYAML(node *yaml.Node) error {
switch node.Kind {
case yaml.ScalarNode:
var task string
if err := node.Decode(&task); err != nil {
return errors.NewTaskfileDecodeError(err, node)
}
d.Task = task
return nil
case yaml.MappingNode:
var taskCall struct {
Task string `yaml:"task"`
For *For
Vars *Vars
Silent bool
InheritOutdated bool `yaml:"inherit_outdated"`
}
if err := node.Decode(&taskCall); err != nil {
return errors.NewTaskfileDecodeError(err, node)
}
d.Task = taskCall.Task
d.For = taskCall.For
d.Vars = taskCall.Vars
d.Silent = taskCall.Silent
d.InheritOutdated = taskCall.InheritOutdated
return nil
}
return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("dependency")
}