Skip to content

Task directory precedence #2545

@ysmilda

Description

@ysmilda

Description

I expected/hoped that defining a dir for a task would mean that any command (e.g cmds, calling other tasks, or dynamic vars) would be executed with that directory as a base. The same goes for including a Taskfile with a dir entry.

But this task definition shows that vars and subcommands are executed against the directory the Taskfile was found in. The same goes for includes with a dir entry set, these are also executed against the parent Taskfiles directory.

  one:
    dir: some/path
    cmds:
      - echo "{{.dir}}"
      - pwd
      - task: two
    vars:
      dir: 
        sh: pwd
  
  two:
    cmds:
      - pwd

This makes it difficult to define reusable tasks which act on the directory of the calling task.

If this is the intended functionality, could a flag be added to allow the behaviour that I was expecting?

Version

3.45.5

Operating system

macOS

Experiments Enabled

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions