1
0
mirror of https://github.com/go-task/task.git synced 2025-06-27 00:51:05 +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" "errors"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"runtime" "runtime"
"strings" "strings"
"text/template" "text/template"
@ -84,6 +85,18 @@ func init() {
"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 },
"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() templateFuncs = sprig.TxtFuncMap()