1
0
mirror of https://github.com/go-task/task.git synced 2025-05-29 23:17:53 +02:00

feat: new dynamic variable syntax

This commit is contained in:
Pete Davison 2023-11-30 01:56:30 +00:00
parent 12a8fb0581
commit 1a12b94bd3

View File

@ -2,6 +2,7 @@ package taskfile
import ( import (
"fmt" "fmt"
"strings"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
@ -84,6 +85,13 @@ func (v *Var) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&value); err != nil { if err := node.Decode(&value); err != nil {
return err return err
} }
// If the value is a string and it starts with $, then it's a shell command
if str, ok := value.(string); ok {
if str, ok = strings.CutPrefix(str, "$"); ok {
v.Sh = str
return nil
}
}
v.Value = value v.Value = value
return nil return nil
} }