Description
Love the new if conditions feature.
If a task has an if condition that uses on a dynamic variable, that condition will not evaluate correctly. This works correctly with a static variable as the included test case shows.
Executing task -v and task -v conditional-on-task-dynamicvar on the included test case will both output task: if condition not met - skipped: "conditional-on-task-dynamicvar"
Version
3.47.0
Operating system
Linux, Windows
Experiments Enabled
No response
Example Taskfile
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
tasks:
default:
cmds:
- task: conditional-on-command
- task: conditional-on-command-dynamicvar
- task: conditional-on-task
- task: conditional-on-task-dynamicvar
conditional-on-command:
vars:
ENABLE_FEATURE: "true"
cmds:
- cmd: echo "Feature is enabled"
if: '{{eq .ENABLE_FEATURE "true"}}'
- cmd: echo "Feature is disabled"
if: '{{ne .ENABLE_FEATURE "true"}}'
conditional-on-command-dynamicvar:
vars:
ENABLE_FEATURE:
sh: 'echo "true"'
cmds:
- cmd: echo "Feature is enabled"
if: '{{eq .ENABLE_FEATURE "true"}}'
- cmd: echo "Feature is disabled"
if: '{{ne .ENABLE_FEATURE "true"}}'
conditional-on-task:
vars:
ENABLE_FEATURE: "true"
if: '{{eq .ENABLE_FEATURE "true"}}'
cmds:
- cmd: echo "Feature is enabled"
conditional-on-task-dynamicvar:
vars:
ENABLE_FEATURE:
sh: 'echo "true"'
if: '{{eq .ENABLE_FEATURE "true"}}'
cmds:
- cmd: echo "Feature is enabled"
Description
Love the new if conditions feature.
If a task has an if condition that uses on a dynamic variable, that condition will not evaluate correctly. This works correctly with a static variable as the included test case shows.
Executing
task -vandtask -v conditional-on-task-dynamicvaron the included test case will both outputtask: if condition not met - skipped: "conditional-on-task-dynamicvar"Version
3.47.0
Operating system
Linux, Windows
Experiments Enabled
No response
Example Taskfile