mirror of
https://github.com/go-task/task.git
synced 2025-05-27 23:08:16 +02:00
feat: new dynamic variable syntax
This commit is contained in:
parent
12a8fb0581
commit
1a12b94bd3
@ -2,6 +2,7 @@ package taskfile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
@ -84,6 +85,13 @@ func (v *Var) UnmarshalYAML(node *yaml.Node) error {
|
||||
if err := node.Decode(&value); err != nil {
|
||||
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
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user