mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
feat: parse templates in collection-type variables (#1526)
* refactor: replacer * feat: move traverser to deepcopy package * feat: nested map variable templating * refactor: ReplaceVar function * feat: test cases * fix: TraverseStringsFunc copy value instead of pointer
This commit is contained in:
@@ -22,11 +22,10 @@ func Dotenv(c *compiler.Compiler, tf *ast.Taskfile, dir string) (*ast.Vars, erro
|
||||
}
|
||||
|
||||
env := &ast.Vars{}
|
||||
|
||||
tr := templater.Templater{Vars: vars}
|
||||
cache := &templater.Cache{Vars: vars}
|
||||
|
||||
for _, dotEnvPath := range tf.Dotenv {
|
||||
dotEnvPath = tr.Replace(dotEnvPath)
|
||||
dotEnvPath = templater.Replace(dotEnvPath, cache)
|
||||
if dotEnvPath == "" {
|
||||
continue
|
||||
}
|
||||
|
@@ -60,11 +60,11 @@ func Read(
|
||||
}
|
||||
|
||||
err = tf.Includes.Range(func(namespace string, include ast.Include) error {
|
||||
tr := templater.Templater{Vars: tf.Vars}
|
||||
cache := &templater.Cache{Vars: tf.Vars}
|
||||
include = ast.Include{
|
||||
Namespace: include.Namespace,
|
||||
Taskfile: tr.Replace(include.Taskfile),
|
||||
Dir: tr.Replace(include.Dir),
|
||||
Taskfile: templater.Replace(include.Taskfile, cache),
|
||||
Dir: templater.Replace(include.Dir, cache),
|
||||
Optional: include.Optional,
|
||||
Internal: include.Internal,
|
||||
Aliases: include.Aliases,
|
||||
@@ -72,7 +72,7 @@ func Read(
|
||||
Vars: include.Vars,
|
||||
BaseDir: include.BaseDir,
|
||||
}
|
||||
if err := tr.Err(); err != nil {
|
||||
if err := cache.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user