Skip to content

Add special variable for task working directory #2102

@jaynis

Description

@jaynis

Description

There are various special variables available but none of them reflects the working directory of a respective task. The ones that come closest are:

  • USER_WORKING_DIR which contains the directory where task has been called from, but does not honor the -d <dir> command line parameter
    and
  • TASK_DIR which merely contains what has been configured under dir: in a task of the Taskfile.yml file and does not even resolve template expressions.

I see two different solutions to this problem:

  1. Either change the behavior of USER_WORKING_DIR so that it takes the -d parameter into account, because I see only very little benefit in having a variable which contains the directory where task has been called from when a different working directory has been explicitly set with -d
  2. Introduce a new variable such as TASK_WORKING_DIR which contains the desired dir and does not break the current behavior of USER_WORKING_DIR.

The current use case which I have is as follows: I have a root directory containing a Taskfile.yml file and some subdirectories which doesnt have Taskfiles.yml files. I now want to reuse the logic of the Taskfile.yml from the root directory in the subdirectories as described here. This works well if I navigate to a subdirectory and call the respective task from there, however, when I call task from the root directory and specify the subdirectory with the -d parameter it doesnt work as USER_WORKING_DIR still contains the root directory as outlined above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions