mirror of
https://github.com/go-task/task.git
synced 2025-03-05 15:05:42 +02:00
parent
1107f691ea
commit
e086b654aa
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Fixed environment from .env files not being available as variables
|
||||
([#379](https://github.com/go-task/task/issues/379)).
|
||||
|
||||
## v3.2.1
|
||||
|
||||
- Fixed some bugs and regressions regarding dynamic variables and directories
|
||||
|
@ -20,6 +20,7 @@ var _ compiler.Compiler = &CompilerV3{}
|
||||
type CompilerV3 struct {
|
||||
Dir string
|
||||
|
||||
TaskfileEnv *taskfile.Vars
|
||||
TaskfileVars *taskfile.Vars
|
||||
|
||||
Logger *logger.Logger
|
||||
@ -54,6 +55,9 @@ func (c *CompilerV3) GetVariables(t *taskfile.Task, call taskfile.Call) (*taskfi
|
||||
}
|
||||
rangeFunc := getRangeFunc(c.Dir)
|
||||
|
||||
if err := c.TaskfileEnv.Range(rangeFunc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.TaskfileVars.Range(rangeFunc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
1
task.go
1
task.go
@ -168,6 +168,7 @@ func (e *Executor) Setup() error {
|
||||
} else {
|
||||
e.Compiler = &compilerv3.CompilerV3{
|
||||
Dir: e.Dir,
|
||||
TaskfileEnv: e.Taskfile.Env,
|
||||
TaskfileVars: e.Taskfile.Vars,
|
||||
Logger: e.Logger,
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ func TestVarsV3(t *testing.T) {
|
||||
"var-order.txt": "ABCDEF\n",
|
||||
"dependent-sh.txt": "123456\n",
|
||||
"with-call.txt": "Hi, ABC123!\n",
|
||||
"from-dot-env.txt": "From .env file\n",
|
||||
},
|
||||
}
|
||||
tt.Run(t)
|
||||
|
1
testdata/vars/v3/.env
vendored
Normal file
1
testdata/vars/v3/.env
vendored
Normal file
@ -0,0 +1 @@
|
||||
DOT_ENV_VAR=From .env file
|
5
testdata/vars/v3/Taskfile.yml
vendored
5
testdata/vars/v3/Taskfile.yml
vendored
@ -1,5 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
dotenv: [.env]
|
||||
|
||||
vars:
|
||||
VAR_A: A
|
||||
VAR_B: '{{.VAR_A}}B'
|
||||
@ -15,6 +17,7 @@ tasks:
|
||||
- task: var-order
|
||||
- task: dependent-sh
|
||||
- task: with-call
|
||||
- task: from-dot-env
|
||||
|
||||
missing-var: echo '{{.NON_EXISTING_VAR}}' > missing-var.txt
|
||||
|
||||
@ -44,3 +47,5 @@ tasks:
|
||||
MESSAGE: Hi, {{.ABC123}}!
|
||||
cmds:
|
||||
- echo "{{.MESSAGE}}" > with-call.txt
|
||||
|
||||
from-dot-env: echo '{{.DOT_ENV_VAR}}' > from-dot-env.txt
|
||||
|
Loading…
x
Reference in New Issue
Block a user