mirror of
https://github.com/go-task/task.git
synced 2026-06-15 11:51:41 +00:00
Rename the experiment from SCOPED_INCLUDES to SCOPED_TASKFILES to better
reflect its expanded scope. This experiment now provides:
1. Variable scoping (existing): includes see only their own vars + parent vars
2. Environment namespace (new): env vars accessible via {{.env.XXX}}
With TASK_X_SCOPED_TASKFILES=1:
- {{.VAR}} accesses vars only (scoped per include)
- {{.env.VAR}} accesses env (OS + Taskfile env:, inherited)
- {{.TASK}} and other special vars remain at root level
This is a breaking change for the experimental feature:
- {{.PATH}} no longer works, use {{.env.PATH}} instead
- Env vars are no longer at root level in templates
39 lines
872 B
YAML
39 lines
872 B
YAML
version: "3"
|
|
|
|
env:
|
|
ROOT_ENV: env_from_root
|
|
SHARED_ENV: shared_from_root
|
|
|
|
vars:
|
|
ROOT_VAR: from_root
|
|
|
|
includes:
|
|
a: ./inc_a
|
|
b: ./inc_b
|
|
|
|
tasks:
|
|
default:
|
|
desc: Test scoped includes - vars should be isolated
|
|
cmds:
|
|
- task: a:print
|
|
- task: b:print
|
|
|
|
print-root-var:
|
|
desc: Print ROOT_VAR from root
|
|
cmds:
|
|
- echo "ROOT_VAR={{.ROOT_VAR}}"
|
|
|
|
print-env:
|
|
desc: Print env vars using {{.env.XXX}} syntax
|
|
cmds:
|
|
- echo "ROOT_ENV={{.env.ROOT_ENV}}"
|
|
- echo "SHARED_ENV={{.env.SHARED_ENV}}"
|
|
- echo "PATH_EXISTS={{if .env.PATH}}yes{{else}}no{{end}}"
|
|
|
|
test-env-separation:
|
|
desc: Test that env is NOT at root level in scoped mode
|
|
cmds:
|
|
# In scoped mode, {{.ROOT_ENV}} should be empty (env not at root)
|
|
# In legacy mode, {{.ROOT_ENV}} would have the value
|
|
- echo "ROOT_ENV_AT_ROOT={{.ROOT_ENV}}"
|