1
0
mirror of https://github.com/go-task/task.git synced 2025-01-22 05:10:17 +02:00

Add "ToSlash" and "FromSlash" to template functions

Closes #22
This commit is contained in:
Andrey Nering 2017-04-16 17:16:56 -03:00
parent c1f9f73184
commit 0d84549b2a

View File

@ -7,6 +7,7 @@ import (
"errors"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"text/template"
@ -84,6 +85,18 @@ func init() {
"OS": func() string { return runtime.GOOS },
"ARCH": func() string { return runtime.GOARCH },
"IsSH": func() bool { return execext.ShExists },
"FromSlash": func(path string) string {
if execext.ShExists {
return path
}
return filepath.FromSlash(path)
},
"ToSlash": func(path string) string {
if execext.ShExists {
return path
}
return filepath.ToSlash(path)
},
}
templateFuncs = sprig.TxtFuncMap()