1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Allow vars in dotenv paths, including environment variables

Closes #453
Closes #434
Ref #433

Co-authored-by: Andrey Nering <andrey@nering.com.br>
This commit is contained in:
Nicolas Fouché
2021-06-05 15:54:10 -03:00
committed by Andrey Nering
parent cded9af90f
commit 08265ed1d7
14 changed files with 165 additions and 28 deletions

17
task.go
View File

@@ -176,6 +176,23 @@ func (e *Executor) Setup() error {
}
}
if v >= 3.0 {
env, err := read.Dotenv(e.Compiler, e.Taskfile, e.Dir)
if err != nil {
return err
}
err = env.Range(func(key string, value taskfile.Var) error {
if _, ok := e.Taskfile.Env.Mapping[key]; !ok {
e.Taskfile.Env.Set(key, value)
}
return nil
})
if err != nil {
return err
}
}
if v < 2.1 && e.Taskfile.Output != "" {
return fmt.Errorf(`task: Taskfile option "output" is only available starting on Taskfile version v2.1`)
}