Exchange values between task and deps using dotenv files. by trulede · Pull Request #2711 · go-task/task
This PR allows the exchange of variables between tasks, and depend tasks, using the dotenv mechanism.
If a task has deps and dotenv then the dotenv files are reloaded which makes them available in the environment of subsequent task commands.
Using this method the task does not need to be recompiled, which avoids complexities which might occur if templated variables in a task would change.
Fixes #1381 (and many others)
Fixes #1575
Fixes #2385
Fixes #1449
Alternative to #1746 (improves upon)
Related to #1627 (alternative to)
In general, works as you might expect:
version: '3'
tasks:
gen:
cmds:
- echo "BAR=bar" > .genenv
default:
dotenv:
- .genenv
deps:
- gen
cmds:
- echo "BAR=$BAR"