1
0
mirror of https://github.com/go-task/task.git synced 2025-06-25 00:47:04 +02:00

Use functions defined on github.com/Masterminds/sprig

Closes #21
This commit is contained in:
Andrey Nering
2017-04-16 16:53:11 -03:00
parent c105294f61
commit c1f9f73184

View File

@ -14,6 +14,7 @@ import (
"github.com/go-task/task/execext" "github.com/go-task/task/execext"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/Masterminds/sprig"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -76,10 +77,19 @@ func (t *Task) handleVariables() (map[string]string, error) {
return localVariables, nil return localVariables, nil
} }
var templateFuncs = template.FuncMap{ var templateFuncs template.FuncMap
func init() {
taskFuncs := template.FuncMap{
"OS": func() string { return runtime.GOOS }, "OS": func() string { return runtime.GOOS },
"ARCH": func() string { return runtime.GOARCH }, "ARCH": func() string { return runtime.GOARCH },
"IsSH": func() bool { return execext.ShExists }, "IsSH": func() bool { return execext.ShExists },
}
templateFuncs = sprig.TxtFuncMap()
for k, v := range taskFuncs {
templateFuncs[k] = v
}
} }
// ReplaceVariables writes vars into initial string // ReplaceVariables writes vars into initial string