mirror of
https://github.com/go-task/task.git
synced 2025-01-22 05:10:17 +02:00
fix: expand task-level dotenv in brackets
This commit is contained in:
parent
cd259a741f
commit
4cb0450dee
12
task_test.go
12
task_test.go
@ -1563,6 +1563,18 @@ func TestTaskDotenv(t *testing.T) {
|
||||
tt.Run(t)
|
||||
}
|
||||
|
||||
func TestTaskDotenvWithBrackets(t *testing.T) {
|
||||
tt := fileContentTest{
|
||||
Dir: "testdata/dotenv_task/default",
|
||||
Target: "dotenv",
|
||||
TrimSpace: true,
|
||||
Files: map[string]string{
|
||||
"dotenv-2.txt": "foo",
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
}
|
||||
|
||||
func TestTaskDotenvFail(t *testing.T) {
|
||||
tt := fileContentTest{
|
||||
Dir: "testdata/dotenv_task/default",
|
||||
|
1
testdata/dotenv_task/default/Taskfile.yml
vendored
1
testdata/dotenv_task/default/Taskfile.yml
vendored
@ -8,6 +8,7 @@ tasks:
|
||||
dotenv: ['.env']
|
||||
cmds:
|
||||
- echo "$FOO" > dotenv.txt
|
||||
- echo "{{.FOO}}" > dotenv-2.txt
|
||||
|
||||
dotenv-overridden-by-env:
|
||||
dotenv: ['.env']
|
||||
|
@ -125,6 +125,7 @@ func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
envCache := new.Env.ToCacheMap()
|
||||
|
||||
if len(origTask.Cmds) > 0 {
|
||||
new.Cmds = make([]*ast.Cmd, 0, len(origTask.Cmds))
|
||||
@ -161,7 +162,7 @@ func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task,
|
||||
continue
|
||||
}
|
||||
newCmd := cmd.DeepCopy()
|
||||
newCmd.Cmd = templater.Replace(cmd.Cmd, cache)
|
||||
newCmd.Cmd = templater.ReplaceWithExtra(cmd.Cmd, cache, envCache)
|
||||
newCmd.Task = templater.Replace(cmd.Task, cache)
|
||||
newCmd.Vars = templater.ReplaceVars(cmd.Vars, cache)
|
||||
new.Cmds = append(new.Cmds, newCmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user