task icon indicating copy to clipboard operation
task copied to clipboard

docs example for `preconditions` doesn't work as written

Open phred opened this issue 2 years ago • 2 comments

See: https://github.com/go-task/task/blob/b681ef98689fa0bd004413ccf462765b33b15b32/docs/docs/api_reference.md?plain=1#L351

The docs uses precondition which, in testing, is ignored by Task.

Example Taskfile:

version: '3'

tasks:
  broken:
    precondition: test -f nonexistent
    cmds:
      - "echo 'precondition met, wtf'"

  works:
    preconditions:
      - test -f nonexistent
    cmds:
      - "echo 'precondition met, wtf'"

  oneliner:
    preconditions: [ test -f nonexistent ]
    cmds:
      - "echo 'precondition met, wtf'"

The broken task matches what the docs show, and it will always run. The works and oneliner tasks won't run unless you create a file named nonexistent.

I have only tested this on 3.25.0, but looking at the code it appears that preconditions is the correct property.

phred avatar Oct 22 '23 02:10 phred

Same thing happens here.

vkhobor avatar Feb 10 '24 03:02 vkhobor

Seems like a documentation error (with the "tip"). Preconditions are defined as a list, and implemented as such.

trulede avatar Mar 30 '24 11:03 trulede

Yes, preconditions are a list. The doc is now up to date

vmaerten avatar May 19 '24 15:05 vmaerten