mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
8b3c34c308
Also, fix handling of Taskfile by making the version an instance of `semver.Constraints` instead of `semver.Version`. This makes the version works as described on TASKFILE_VERSIONS.md document, i.e. version "2" will include "2.x" features but version "2.0" not.
39 lines
778 B
Go
39 lines
778 B
Go
package taskfile
|
|
|
|
// Taskfile represents a Taskfile.yml
|
|
type Taskfile struct {
|
|
Version string
|
|
Expansions int
|
|
Output string
|
|
Vars Vars
|
|
Tasks Tasks
|
|
}
|
|
|
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
|
func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
if err := unmarshal(&tf.Tasks); err == nil {
|
|
tf.Version = "1"
|
|
return nil
|
|
}
|
|
|
|
var taskfile struct {
|
|
Version string
|
|
Expansions int
|
|
Output string
|
|
Vars Vars
|
|
Tasks Tasks
|
|
}
|
|
if err := unmarshal(&taskfile); err != nil {
|
|
return err
|
|
}
|
|
tf.Version = taskfile.Version
|
|
tf.Expansions = taskfile.Expansions
|
|
tf.Output = taskfile.Output
|
|
tf.Vars = taskfile.Vars
|
|
tf.Tasks = taskfile.Tasks
|
|
if tf.Expansions <= 0 {
|
|
tf.Expansions = 2
|
|
}
|
|
return nil
|
|
}
|