mirror of
https://github.com/go-task/task.git
synced 2025-06-29 00:51:43 +02:00
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Improve error reporting when parsing YAML: in some situations where you
|
||||||
|
would just see an generic error, you'll now see the actual error with
|
||||||
|
more detail: the YAML line the failed to parse, for exemple
|
||||||
|
[#467](https://github.com/go-task/task/issues/467).
|
||||||
- A JSON Schema was published [here](https://json.schemastore.org/taskfile.json)
|
- A JSON Schema was published [here](https://json.schemastore.org/taskfile.json)
|
||||||
- and is automatically being used by some editors like Visual Studio Code
|
- and is automatically being used by some editors like Visual Studio Code
|
||||||
([#135](https://github.com/go-task/task/issues/135)).
|
([#135](https://github.com/go-task/task/issues/135)).
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package taskfile
|
package taskfile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,13 +19,6 @@ type Dep struct {
|
|||||||
Vars *Vars
|
Vars *Vars
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrCantUnmarshalCmd is returned for invalid command YAML
|
|
||||||
ErrCantUnmarshalCmd = errors.New("task: can't unmarshal cmd value")
|
|
||||||
// ErrCantUnmarshalDep is returned for invalid dependency YAML
|
|
||||||
ErrCantUnmarshalDep = errors.New("task: can't unmarshal dep value")
|
|
||||||
)
|
|
||||||
|
|
||||||
// UnmarshalYAML implements yaml.Unmarshaler interface
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
||||||
func (c *Cmd) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *Cmd) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
var cmd string
|
var cmd string
|
||||||
@ -53,12 +45,12 @@ func (c *Cmd) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
Task string
|
Task string
|
||||||
Vars *Vars
|
Vars *Vars
|
||||||
}
|
}
|
||||||
if err := unmarshal(&taskCall); err == nil {
|
if err := unmarshal(&taskCall); err != nil {
|
||||||
c.Task = taskCall.Task
|
return err
|
||||||
c.Vars = taskCall.Vars
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return ErrCantUnmarshalCmd
|
c.Task = taskCall.Task
|
||||||
|
c.Vars = taskCall.Vars
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements yaml.Unmarshaler interface
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
||||||
@ -72,10 +64,10 @@ func (d *Dep) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
Task string
|
Task string
|
||||||
Vars *Vars
|
Vars *Vars
|
||||||
}
|
}
|
||||||
if err := unmarshal(&taskCall); err == nil {
|
if err := unmarshal(&taskCall); err != nil {
|
||||||
d.Task = taskCall.Task
|
return err
|
||||||
d.Vars = taskCall.Vars
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return ErrCantUnmarshalDep
|
d.Task = taskCall.Task
|
||||||
|
d.Vars = taskCall.Vars
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,6 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrCantUnmarshalIncludedTaskfile is returned for invalid var YAML.
|
|
||||||
ErrCantUnmarshalIncludedTaskfile = errors.New("task: can't unmarshal included value")
|
|
||||||
)
|
|
||||||
|
|
||||||
// IncludedTaskfile represents information about included tasksfile
|
// IncludedTaskfile represents information about included tasksfile
|
||||||
type IncludedTaskfile struct {
|
type IncludedTaskfile struct {
|
||||||
Taskfile string
|
Taskfile string
|
||||||
@ -98,12 +93,11 @@ func (it *IncludedTaskfile) UnmarshalYAML(unmarshal func(interface{}) error) err
|
|||||||
Taskfile string
|
Taskfile string
|
||||||
Dir string
|
Dir string
|
||||||
}
|
}
|
||||||
if err := unmarshal(&includedTaskfile); err == nil {
|
if err := unmarshal(&includedTaskfile); err != nil {
|
||||||
it.Dir = includedTaskfile.Dir
|
return err
|
||||||
it.Taskfile = includedTaskfile.Taskfile
|
|
||||||
it.AdvancedImport = true
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
it.Dir = includedTaskfile.Dir
|
||||||
return ErrCantUnmarshalIncludedTaskfile
|
it.Taskfile = includedTaskfile.Taskfile
|
||||||
|
it.AdvancedImport = true
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package taskfile
|
package taskfile
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Tasks represents a group of tasks
|
// Tasks represents a group of tasks
|
||||||
type Tasks map[string]*Task
|
type Tasks map[string]*Task
|
||||||
|
|
||||||
@ -28,11 +24,6 @@ type Task struct {
|
|||||||
IgnoreError bool
|
IgnoreError bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrCantUnmarshalTask is returned for invalid task YAML
|
|
||||||
ErrCantUnmarshalTask = errors.New("task: can't unmarshal task value")
|
|
||||||
)
|
|
||||||
|
|
||||||
func (t *Task) Name() string {
|
func (t *Task) Name() string {
|
||||||
if t.Label != "" {
|
if t.Label != "" {
|
||||||
return t.Label
|
return t.Label
|
||||||
@ -71,26 +62,24 @@ func (t *Task) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
Prefix string
|
Prefix string
|
||||||
IgnoreError bool `yaml:"ignore_error"`
|
IgnoreError bool `yaml:"ignore_error"`
|
||||||
}
|
}
|
||||||
if err := unmarshal(&task); err == nil {
|
if err := unmarshal(&task); err != nil {
|
||||||
t.Cmds = task.Cmds
|
return err
|
||||||
t.Deps = task.Deps
|
|
||||||
t.Label = task.Label
|
|
||||||
t.Desc = task.Desc
|
|
||||||
t.Summary = task.Summary
|
|
||||||
t.Sources = task.Sources
|
|
||||||
t.Generates = task.Generates
|
|
||||||
t.Status = task.Status
|
|
||||||
t.Preconditions = task.Preconditions
|
|
||||||
t.Dir = task.Dir
|
|
||||||
t.Vars = task.Vars
|
|
||||||
t.Env = task.Env
|
|
||||||
t.Silent = task.Silent
|
|
||||||
t.Method = task.Method
|
|
||||||
t.Prefix = task.Prefix
|
|
||||||
t.IgnoreError = task.IgnoreError
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
t.Cmds = task.Cmds
|
||||||
return ErrCantUnmarshalTask
|
t.Deps = task.Deps
|
||||||
|
t.Label = task.Label
|
||||||
|
t.Desc = task.Desc
|
||||||
|
t.Summary = task.Summary
|
||||||
|
t.Sources = task.Sources
|
||||||
|
t.Generates = task.Generates
|
||||||
|
t.Status = task.Status
|
||||||
|
t.Preconditions = task.Preconditions
|
||||||
|
t.Dir = task.Dir
|
||||||
|
t.Vars = task.Vars
|
||||||
|
t.Env = task.Env
|
||||||
|
t.Silent = task.Silent
|
||||||
|
t.Method = task.Method
|
||||||
|
t.Prefix = task.Prefix
|
||||||
|
t.IgnoreError = task.IgnoreError
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,6 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrCantUnmarshalVar is returned for invalid var YAML.
|
|
||||||
ErrCantUnmarshalVar = errors.New("task: can't unmarshal var value")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Vars is a string[string] variables map.
|
// Vars is a string[string] variables map.
|
||||||
type Vars struct {
|
type Vars struct {
|
||||||
Keys []string
|
Keys []string
|
||||||
@ -124,10 +119,9 @@ func (v *Var) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
var sh struct {
|
var sh struct {
|
||||||
Sh string
|
Sh string
|
||||||
}
|
}
|
||||||
if err := unmarshal(&sh); err == nil {
|
if err := unmarshal(&sh); err != nil {
|
||||||
v.Sh = sh.Sh
|
return err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
v.Sh = sh.Sh
|
||||||
return ErrCantUnmarshalVar
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user