Open 100gle opened 1 year ago
+1 Well it seems more like that all taskfile defined env is simply not substituted in dynamic vars.
env:
IMAGE_DIR: "HELLO"
# or
# dotenv: [".env"]
tasks:
mkdisk:
vars:
imageDir: '{{ env "IMAGE_DIR" }}'
cmds:
- echo '{{.imageDir}}'
This is also happening to me, the following doesn't work as well:
vars:
TEST: "{{.USER_WORKING_DIR | toSlash}}"
dotenv:
- ".env"
tasks:
test:
desc: "A test task"
cmds:
- echo 'This is a test!'
This works as expected when defining vars at the task level:
dotenv:
- sandwich.env
vars:
SANDWICH: '{{ env "SANDWICH" | default .DEFAULT_SANDWICH }}.sandwich'
tasks:
sandwich:
vars:
SANDWICH_PATH: '{{ joinPath .ROOT_DIR .SANDWICH_DIR .SANDWICH | osClean }}'
cmds:
- echo {{ relPath .ROOT_DIR .SANDWICH_PATH | toSlash }}
$ task sandwich
task: [sandwich] echo sandwiches/cheese-and-pickle.sandwich
sandwiches/cheese-and-pickle.sandwich
It breaks when a template pipeline is used at the global var level:
dotenv:
- sandwich.env
vars:
SANDWICH: '{{ env "SANDWICH" | default .DEFAULT_SANDWICH }}.sandwich'
SANDWICH_PATH: '{{ joinPath .ROOT_DIR .SANDWICH_DIR .SANDWICH | osClean }}'
tasks:
sandwich:
cmds:
- echo {{ relPath .ROOT_DIR .SANDWICH_PATH | toSlash }}
$ task sandwich
template: :1:12: executing "" at <.ROOT_DIR>: invalid value; expected string
sandwich.env
for reference:
SANDWICH_DIR=sandwiches
DEFAULT_SANDWICH=cheese-and-pickle
How to reproduce it?
When I don't include dotenv key in config file, all things work well:
But when I add
dotenv
keys in config file with an empty.env
file(created but no content):then run task again and the console will show: