1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Add hability to globally set environment variables

Closes #138
This commit is contained in:
Andrey Nering
2019-01-02 12:05:40 -02:00
parent 5572e31fd4
commit aac6c5a1c7
6 changed files with 51 additions and 16 deletions

View File

@@ -30,7 +30,7 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
Status: r.ReplaceSlice(origTask.Status),
Dir: r.Replace(origTask.Dir),
Vars: nil,
Env: r.ReplaceVars(origTask.Env),
Env: nil,
Silent: origTask.Silent,
Method: r.Replace(origTask.Method),
Prefix: r.Replace(origTask.Prefix),
@@ -46,6 +46,14 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
if new.Prefix == "" {
new.Prefix = new.Task
}
new.Env = make(taskfile.Vars, len(e.Taskfile.Env)+len(origTask.Env))
for k, v := range r.ReplaceVars(e.Taskfile.Env) {
new.Env[k] = v
}
for k, v := range r.ReplaceVars(origTask.Env) {
new.Env[k] = v
}
for k, v := range new.Env {
static, err := e.Compiler.HandleDynamicVar(v)
if err != nil {