mirror of
https://github.com/go-task/task.git
synced 2025-04-25 12:25:07 +02:00
Add ExeExt template function
This commit is contained in:
parent
398a2c519c
commit
561349c820
@ -309,6 +309,8 @@ Task also adds the following functions:
|
|||||||
path format to `/`.
|
path format to `/`.
|
||||||
- `FromSlash`: Oposite of `ToSlash`. Does nothing on Unix, but on Windows
|
- `FromSlash`: Oposite of `ToSlash`. Does nothing on Unix, but on Windows
|
||||||
converts a string from `\` path format to `/`.
|
converts a string from `\` path format to `/`.
|
||||||
|
- `ExeExt`: Returns the right executable extension for the current OS
|
||||||
|
(`".exe"` for Windows, `""` for others).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -91,6 +91,12 @@ func init() {
|
|||||||
"ToSlash": func(path string) string {
|
"ToSlash": func(path string) string {
|
||||||
return filepath.ToSlash(path)
|
return filepath.ToSlash(path)
|
||||||
},
|
},
|
||||||
|
"ExeExt": func() string {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return ".exe"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
templateFuncs = sprig.TxtFuncMap()
|
templateFuncs = sprig.TxtFuncMap()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user