1
0
mirror of https://github.com/go-task/task.git synced 2025-11-29 22:48:03 +02:00

Refactor: Add SmartJoin to handle IsAbs automatically

This commit is contained in:
Andrey Nering
2022-08-06 18:19:07 -03:00
parent c20842e7cd
commit c4e10ef0aa
12 changed files with 76 additions and 71 deletions

View File

@@ -2,11 +2,11 @@ package read
import (
"os"
"path/filepath"
"github.com/joho/godotenv"
"github.com/go-task/task/v3/internal/compiler"
"github.com/go-task/task/v3/internal/filepathext"
"github.com/go-task/task/v3/internal/templater"
"github.com/go-task/task/v3/taskfile"
)
@@ -27,10 +27,8 @@ func Dotenv(c compiler.Compiler, tf *taskfile.Taskfile, dir string) (*taskfile.V
for _, dotEnvPath := range tf.Dotenv {
dotEnvPath = tr.Replace(dotEnvPath)
dotEnvPath = filepathext.SmartJoin(dir, dotEnvPath)
if !filepath.IsAbs(dotEnvPath) {
dotEnvPath = filepath.Join(dir, dotEnvPath)
}
if _, err := os.Stat(dotEnvPath); os.IsNotExist(err) {
continue
}