mirror of
https://github.com/go-task/task.git
synced 2026-07-08 22:46:07 +00:00
Move all structs related to Taskfile to its own package
This commit is contained in:
26
internal/taskfile/taskfile.go
Normal file
26
internal/taskfile/taskfile.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package taskfile
|
||||
|
||||
// Taskfile represents a Taskfile.yml
|
||||
type Taskfile struct {
|
||||
// TODO: version is still not used
|
||||
Version int
|
||||
Tasks Tasks
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler interface
|
||||
func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
if err := unmarshal(&tf.Tasks); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var taskfile struct {
|
||||
Version int
|
||||
Tasks Tasks
|
||||
}
|
||||
if err := unmarshal(&taskfile); err != nil {
|
||||
return err
|
||||
}
|
||||
tf.Version = taskfile.Version
|
||||
tf.Tasks = taskfile.Tasks
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user