From c1f9f73184bf523c697f83ea22e897998746b13e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 16 Apr 2017 16:53:11 -0300 Subject: [PATCH] Use functions defined on github.com/Masterminds/sprig Closes #21 --- variable_handling.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/variable_handling.go b/variable_handling.go index 72c4773d..95a85886 100644 --- a/variable_handling.go +++ b/variable_handling.go @@ -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