v3: Do not include Taskfile_{{OS}}.yml automatically

This commit is contained in:
Andrey Nering
2020-05-17 15:42:27 -03:00
parent 6a604b3002
commit 191c34c9c4
4 changed files with 30 additions and 19 deletions

View File

@@ -63,14 +63,20 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
}
}
path = filepath.Join(dir, fmt.Sprintf("Taskfile_%s.yml", runtime.GOOS))
if _, err = os.Stat(path); err == nil {
osTaskfile, err := readTaskfile(path)
if err != nil {
return nil, err
}
if err = taskfile.Merge(t, osTaskfile); err != nil {
return nil, err
v, err := t.ParsedVersion()
if err != nil {
return nil, err
}
if v < 3.0 {
path = filepath.Join(dir, fmt.Sprintf("Taskfile_%s.yml", runtime.GOOS))
if _, err = os.Stat(path); err == nil {
osTaskfile, err := readTaskfile(path)
if err != nil {
return nil, err
}
if err = taskfile.Merge(t, osTaskfile); err != nil {
return nil, err
}
}
}

View File

@@ -1,5 +1,10 @@
package taskfile
import (
"fmt"
"strconv"
)
// Taskfile represents a Taskfile.yml
type Taskfile struct {
Version string
@@ -49,3 +54,12 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
return nil
}
// ParsedVersion returns the version as a float64
func (tf *Taskfile) ParsedVersion() (float64, error) {
v, err := strconv.ParseFloat(tf.Version, 64)
if err != nil {
return 0, fmt.Errorf(`task: Could not parse taskfile version "%s": %v`, tf.Version, err)
}
return v, nil
}