From 61e6dc85da674432ec028965df5278e66ed85ebb Mon Sep 17 00:00:00 2001 From: nxtcoder17 Date: Sun, 20 Oct 2024 10:24:38 +0530 Subject: [PATCH] fix: fixes global dot-env paths, failing with absolute path errors - updates examples to accomodate the changes gh-issue: https://github.com/nxtcoder17/Runfile/issues/19 --- examples/Runfile.yml | 9 ++++++--- pkg/runfile/task-parser.go | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/Runfile.yml b/examples/Runfile.yml index 7e49d37..e08b4f2 100644 --- a/examples/Runfile.yml +++ b/examples/Runfile.yml @@ -11,6 +11,9 @@ includes: env: global_k1: "v1" +dotenv: + - ../.secrets/env + tasks: cook: env: @@ -25,16 +28,16 @@ tasks: # value: "this is default value" # sh: echo this should be the default value gotmpl: len "asdfadf" - dotenv: - - ../.secrets/env + # dotenv: + # - ../.secrets/env cmd: # - sleep 5 # - echo "hi hello" # - echo "value of k1 is '$k1'" # - echo "value of k2 is '$k2'" # - echo "value of k3 is '$k3'" - # - echo "value of key_id (from .dotenv) is '$key_id', ${#key_id}" - echo "hello from cook" + - echo "value of key_id (from .dotenv) is '$key_id', ${#key_id}" - echo "k4 is $k4" - echo "k5 is $k5" diff --git a/pkg/runfile/task-parser.go b/pkg/runfile/task-parser.go index 1a23635..682e5b8 100644 --- a/pkg/runfile/task-parser.go +++ b/pkg/runfile/task-parser.go @@ -37,7 +37,11 @@ func ParseTask(ctx Context, rf *Runfile, task Task) (*ParsedTask, *Error) { } if rf.DotEnv != nil { - m, err := parseDotEnvFiles(rf.DotEnv...) + dotEnvPaths, err := resolveDotEnvFiles(filepath.Dir(rf.attrs.RunfilePath), rf.DotEnv...) + if err != nil { + return nil, err + } + m, err := parseDotEnvFiles(dotEnvPaths...) if err != nil { return nil, err }