Skip to content

defered tasks and commands cannot be silenced #1044

@joelanford

Description

@joelanford

Thanks for your bug report!

Before submitting this issue, please make sure the same problem was
not already reported by someone else.

Please describe the bug you're facing. Consider pasting example
Taskfiles showing how to reproduce the problem.

  • Task version: v3.21.0
  • Operating System: darwin/arm64

I tried to use the typical Cmd structure within a defer-ed command:

version: '3'
tasks:
  hello:
    cmds:
    - mkdir -p testdir
    - defer:
        cmd: "rm -rf testdir"
        silence: true
    - echo "Hello, World!" > testdir/hello.txt
    - cat testdir/hello.txt

And running task hello resulted in:

$ task hello
task: Failed to parse Taskfile.yaml:
yaml: line 6: invalid keys in command

Turns out, both cmd and silence are invalid keys within defer, which was surprising to me since the examples look like the syntax for a non-deferred command.

Not sure if this is a bug or a feature request, but I'm going to guess bug since this was a surprising outcome (to me at least).

Is there some reason that the defer structure isn't just a Cmd that disallows nested defers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions