Skip to content

Cannot loop over task's generated files unless they already exist #2516

@Leonid99

Description

@Leonid99

Description

Trying to run the example from the docs https://taskfile.dev/docs/guide#looping-over-your-task-s-sources-or-generated-files (the one with for: generates). If no file exist (which is the common case -- this task is supposed to create this files), no "cat" happens. If both files already exist, it works as expected. If only one of the files exist, only that file is cat'ed.

❯ rm foo.txt
❯ rm bar.txt
❯ task
❯ touch bar.txt
❯ task
task: [default] cat bar.txt
❯ touch foo.txt
❯ task
task: [default] cat bar.txt
task: [default] cat foo.txt
❯

Version

3.45.5

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

version: '3'

tasks:
  default:
    generates:
      - foo.txt
      - bar.txt
    cmds:
      - for: generates
        cmd: cat {{ .ITEM }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions