1
0
mirror of https://github.com/go-task/task.git synced 2025-10-08 23:02:02 +02:00
Files
task/taskfile/ast/glob.go
Andrey Nering 26cfdb8ae3 refactor: migrate to the official yaml package
The old package is long archived, but the YAML org forked it and will
officially maintain it from now on.

* Old: https://github.com/go-yaml/yaml
* New: https://github.com/yaml/go-yaml
2025-09-21 18:38:27 -03:00

35 lines
569 B
Go

package ast
import (
"go.yaml.in/yaml/v4"
"github.com/go-task/task/v3/errors"
)
type Glob struct {
Glob string
Negate bool
}
func (g *Glob) UnmarshalYAML(node *yaml.Node) error {
switch node.Kind {
case yaml.ScalarNode:
g.Glob = node.Value
return nil
case yaml.MappingNode:
var glob struct {
Exclude string
}
if err := node.Decode(&glob); err != nil {
return errors.NewTaskfileDecodeError(err, node)
}
g.Glob = glob.Exclude
g.Negate = true
return nil
}
return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("glob")
}