1
0
mirror of https://github.com/go-task/task.git synced 2025-03-17 21:08:01 +02:00

Post-fixes and CHANGELOG for #385

This commit is contained in:
Andrey Nering 2020-10-12 21:16:09 -03:00
parent 582a66bb2f
commit 60759a4e3b
2 changed files with 14 additions and 12 deletions

View File

@ -2,6 +2,8 @@
## Unreleased
- Do not error if a specified dotenv file does not exist
([#378](https://github.com/go-task/task/issues/378), [#385](https://github.com/go-task/task/pull/385)).
- Fix panic when you have empty tasks in your Taskfile
([#338](https://github.com/go-task/task/issues/338), [#362](https://github.com/go-task/task/pull/362)).

View File

@ -37,23 +37,23 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
return nil, err
}
if v >= 3.0 && len(t.Dotenv) > 0 {
if v >= 3.0 {
for _, dotEnvPath := range t.Dotenv {
if !filepath.IsAbs(dotEnvPath) {
dotEnvPath = filepath.Join(dir, dotEnvPath)
}
// allow for missing env files since they may be created by a bootstrap task
if _, err := os.Stat(dotEnvPath); !os.IsNotExist(err) {
envs, err := godotenv.Read(dotEnvPath)
if err != nil {
return nil, err
if _, err := os.Stat(dotEnvPath); os.IsNotExist(err) {
continue
}
envs, err := godotenv.Read(dotEnvPath)
if err != nil {
return nil, err
}
for key, value := range envs {
if _, ok := t.Env.Mapping[key]; !ok {
t.Env.Set(key, taskfile.Var{Static: value})
}
for key, value := range envs {
if _, ok := t.Env.Mapping[key]; !ok {
t.Env.Set(key, taskfile.Var{Static: value})
}
}
} else {
}
}
}