Skip to content

Commit

Permalink
fix: load dotenv before vars
Browse files Browse the repository at this point in the history
  • Loading branch information
yordis committed Oct 30, 2023
1 parent b681ef9 commit 6acb54b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,18 @@ func TestDotenvShouldIncludeAllEnvFiles(t *testing.T) {
tt.Run(t)
}

func TestDotenvShouldLoadBeforeTaskVars(t *testing.T) {
tt := fileContentTest{
Dir: "testdata/dotenv/load_dotenv_before_vars",
Target: "default",
TrimSpace: false,
Files: map[string]string{
"include.txt": "AWS_ACCESS_KEY_ID='123'\n",
},
}
tt.Run(t)
}

func TestDotenvShouldErrorWhenIncludingDependantDotenvs(t *testing.T) {
const dir = "testdata/dotenv/error_included_envs"
const entry = "Taskfile.yml"
Expand Down
1 change: 1 addition & 0 deletions testdata/dotenv/load_dotenv_before_vars/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SHT_DO_SPACES_ACCESS_ID=123
11 changes: 11 additions & 0 deletions testdata/dotenv/load_dotenv_before_vars/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

dotenv: ['.env']

tasks:
default:
vars:
AWS_ACCESS_KEY_ID:
sh: echo $SHT_DO_SPACES_ACCESS_ID
cmds:
- echo "AWS_ACCESS_KEY_ID='$AWS_ACCESS_KEY_ID'" > include.txt

0 comments on commit 6acb54b

Please sign in to comment.