mirror of
https://github.com/go-task/task.git
synced 2026-06-25 13:46:13 +00:00
fix(compiler): CLI vars have highest priority in scoped mode
In scoped mode, CLI vars (e.g., `task foo VAR=value`) now correctly
override task-level vars. This is achieved by:
1. Adding a `CLIVars` field to the Compiler struct
2. Storing CLI globals in this field after parsing
3. Applying CLI vars last in scoped mode to ensure they override everything
The order of variable resolution in scoped mode is now:
1. OS env → {{.env.XXX}}
2. Root taskfile env → {{.env.XXX}}
3. Root taskfile vars → {{.VAR}}
4. Include taskfile env/vars (if applicable)
5. IncludeVars (vars passed via includes: section)
6. Task-level vars
7. CLI vars (highest priority)
Legacy mode behavior is unchanged.
This commit is contained in:
6
testdata/scoped_taskfiles/Taskfile.yml
vendored
6
testdata/scoped_taskfiles/Taskfile.yml
vendored
@@ -36,3 +36,9 @@ tasks:
|
||||
# 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}}"
|
||||
|
||||
prout:
|
||||
vars:
|
||||
LOL: prout_from_root
|
||||
cmds:
|
||||
- echo "{{.LOL}}"
|
||||
|
||||
Reference in New Issue
Block a user