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:
parent
12a8fb0581
commit
1a12b94bd3
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user