glob.go 567 B

12345678910111213141516171819202122232425262728293031323334
  1. package ast
  2. import (
  3. "gopkg.in/yaml.v3"
  4. "github.com/go-task/task/v3/errors"
  5. )
  6. type Glob struct {
  7. Glob string
  8. Negate bool
  9. }
  10. func (g *Glob) UnmarshalYAML(node *yaml.Node) error {
  11. switch node.Kind {
  12. case yaml.ScalarNode:
  13. g.Glob = node.Value
  14. return nil
  15. case yaml.MappingNode:
  16. var glob struct {
  17. Exclude string
  18. }
  19. if err := node.Decode(&glob); err != nil {
  20. return errors.NewTaskfileDecodeError(err, node)
  21. }
  22. g.Glob = glob.Exclude
  23. g.Negate = true
  24. return nil
  25. }
  26. return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("glob")
  27. }