1
0
mirror of https://github.com/go-task/task.git synced 2025-03-17 21:08:01 +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/BurntSushi/toml"
"github.com/Masterminds/sprig"
"gopkg.in/yaml.v2"
)
@ -76,10 +77,19 @@ func (t *Task) handleVariables() (map[string]string, error) {
return localVariables, nil
}
var templateFuncs = template.FuncMap{
"OS": func() string { return runtime.GOOS },
"ARCH": func() string { return runtime.GOARCH },
"IsSH": func() bool { return execext.ShExists },
var templateFuncs template.FuncMap
func init() {
taskFuncs := template.FuncMap{
"OS": func() string { return runtime.GOOS },
"ARCH": func() string { return runtime.GOARCH },
"IsSH": func() bool { return execext.ShExists },
}
templateFuncs = sprig.TxtFuncMap()
for k, v := range taskFuncs {
templateFuncs[k] = v
}
}
// ReplaceVariables writes vars into initial string