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:
parent
398a2c519c
commit
561349c820
@ -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:
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user