feat: add support for single cmd task syntax (#1131)

This commit is contained in:
Tim De Pauw
2023-06-11 03:08:28 +02:00
committed by GitHub
parent 59e99caf8a
commit e2c1b3b931
5 changed files with 34 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
case yaml.MappingNode:
var task struct {
Cmds []*Cmd
Cmd *Cmd
Deps []*Dep
Label string
Desc string
@@ -102,7 +103,14 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&task); err != nil {
return err
}
t.Cmds = task.Cmds
if task.Cmd != nil {
if task.Cmds != nil {
return fmt.Errorf("yaml: line %d: task cannot have both cmd and cmds", node.Line)
}
t.Cmds = []*Cmd{task.Cmd}
} else {
t.Cmds = task.Cmds
}
t.Deps = task.Deps
t.Label = task.Label
t.Desc = task.Desc