1
0
mirror of https://github.com/go-task/task.git synced 2025-04-15 11:56:34 +02:00

Add ExeExt template function

This commit is contained in:
Andrey Nering 2017-05-27 10:52:22 -03:00
parent 398a2c519c
commit 561349c820
2 changed files with 8 additions and 0 deletions

View File

@ -309,6 +309,8 @@ Task also adds the following functions:
path format to `/`.
- `FromSlash`: Oposite of `ToSlash`. Does nothing on Unix, but on Windows
converts a string from `\` path format to `/`.
- `ExeExt`: Returns the right executable extension for the current OS
(`".exe"` for Windows, `""` for others).
Example:

View File

@ -91,6 +91,12 @@ func init() {
"ToSlash": func(path string) string {
return filepath.ToSlash(path)
},
"ExeExt": func() string {
if runtime.GOOS == "windows" {
return ".exe"
}
return ""
},
}
templateFuncs = sprig.TxtFuncMap()