Skip to content

Conversation

@philpennock
Copy link
Contributor

The docs explicitly show using a singular "precondition" on a Task at
https://taskfile.dev/reference/schema/#precondition, but the schema only
allowed the plural "preconditions" as a list.

This updates the schema to match the documented easy path.


Examples

Given a Task of:

  format:
    desc: Format the config files for consistency
    precondition: test -f {{.POLICY_FILE}}
    cmds:
      - hujsonfmt -w {{.POLICY_FILE}}

then running task format runs just fine. But without this change, my text
editor displays:

E     precondition: test -f {{.POLICY_FILE}}     ■ Property precondition is not allowed.

Switching to a local schema file and making the change in this PR, the warning
disappears and LSP/yamlls in neovim agrees with Task about what's valid.

The docs explicitly show using a singular "precondition" on a Task at
<https://taskfile.dev/reference/schema/#precondition>, but the schema only
allowed the plural "preconditions" as a list.

This updates the schema to match the documented easy path.
@vmaerten
Copy link
Member

Hello,
It seems the documentation is not up to date. precondition is not allowed. Only preconditions is.

Your example is inccorect. It does not apply precondition.

cf :
image

@philpennock
Copy link
Contributor Author

philpennock commented Apr 24, 2025

Oh drat. I didn't realize that task ignored fields it didn't understand and I didn't adequately test. Okay. This is bogus, sorry.

@philpennock philpennock deleted the pdp/fix-schema-precondition-singular branch April 24, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants