mirror of
https://github.com/go-task/task.git
synced 2025-07-01 00:55:05 +02:00
@ -16,10 +16,13 @@ import (
|
|||||||
var _ compiler.Compiler = &CompilerV2{}
|
var _ compiler.Compiler = &CompilerV2{}
|
||||||
|
|
||||||
type CompilerV2 struct {
|
type CompilerV2 struct {
|
||||||
Dir string
|
Dir string
|
||||||
|
|
||||||
Taskvars taskfile.Vars
|
Taskvars taskfile.Vars
|
||||||
TaskfileVars taskfile.Vars
|
TaskfileVars taskfile.Vars
|
||||||
|
|
||||||
|
Expansions int
|
||||||
|
|
||||||
Logger *logger.Logger
|
Logger *logger.Logger
|
||||||
|
|
||||||
dynamicCache map[string]string
|
dynamicCache map[string]string
|
||||||
@ -34,14 +37,11 @@ type CompilerV2 struct {
|
|||||||
// 5. Environment variables
|
// 5. Environment variables
|
||||||
func (c *CompilerV2) GetVariables(t *taskfile.Task, call taskfile.Call) (taskfile.Vars, error) {
|
func (c *CompilerV2) GetVariables(t *taskfile.Task, call taskfile.Call) (taskfile.Vars, error) {
|
||||||
vr := varResolver{c: c, vars: compiler.GetEnviron()}
|
vr := varResolver{c: c, vars: compiler.GetEnviron()}
|
||||||
vr.merge(c.Taskvars)
|
for _, vars := range []taskfile.Vars{c.Taskvars, c.TaskfileVars, call.Vars, t.Vars} {
|
||||||
vr.merge(c.Taskvars)
|
for i := 0; i < c.Expansions; i++ {
|
||||||
vr.merge(c.TaskfileVars)
|
vr.merge(vars)
|
||||||
vr.merge(c.TaskfileVars)
|
}
|
||||||
vr.merge(call.Vars)
|
}
|
||||||
vr.merge(call.Vars)
|
|
||||||
vr.merge(t.Vars)
|
|
||||||
vr.merge(t.Vars)
|
|
||||||
return vr.vars, vr.err
|
return vr.vars, vr.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,10 @@ package taskfile
|
|||||||
|
|
||||||
// Taskfile represents a Taskfile.yml
|
// Taskfile represents a Taskfile.yml
|
||||||
type Taskfile struct {
|
type Taskfile struct {
|
||||||
Version string
|
Version string
|
||||||
Vars Vars
|
Expansions int
|
||||||
Tasks Tasks
|
Vars Vars
|
||||||
|
Tasks Tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements yaml.Unmarshaler interface
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
||||||
@ -15,15 +16,20 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var taskfile struct {
|
var taskfile struct {
|
||||||
Version string
|
Version string
|
||||||
Vars Vars
|
Expansions int
|
||||||
Tasks Tasks
|
Vars Vars
|
||||||
|
Tasks Tasks
|
||||||
}
|
}
|
||||||
if err := unmarshal(&taskfile); err != nil {
|
if err := unmarshal(&taskfile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tf.Version = taskfile.Version
|
tf.Version = taskfile.Version
|
||||||
|
tf.Expansions = taskfile.Expansions
|
||||||
tf.Vars = taskfile.Vars
|
tf.Vars = taskfile.Vars
|
||||||
tf.Tasks = taskfile.Tasks
|
tf.Tasks = taskfile.Tasks
|
||||||
|
if tf.Expansions <= 0 {
|
||||||
|
tf.Expansions = 2
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user