Skip to content

Commit

Permalink
Merge pull request #20 from nxtcoder17/bug/absolute-dotenv-paths-on-g…
Browse files Browse the repository at this point in the history
…lobal-dotenv

fix: fixes global dot-env paths, failing with absolute path errors
  • Loading branch information
nxtcoder17 authored Oct 20, 2024
2 parents 8835533 + 61e6dc8 commit db127b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions examples/Runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ includes:
env:
global_k1: "v1"

dotenv:
- ../.secrets/env

tasks:
cook:
env:
Expand All @@ -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"

Expand Down
6 changes: 5 additions & 1 deletion pkg/runfile/task-parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit db127b0

Please sign in to comment.