Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special variable for task working directory #2102

Open
jaynis opened this issue Mar 7, 2025 · 0 comments · May be fixed by #2103
Open

Add special variable for task working directory #2102

jaynis opened this issue Mar 7, 2025 · 0 comments · May be fixed by #2103
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@jaynis
Copy link

jaynis commented Mar 7, 2025

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.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Mar 7, 2025
@jaynis jaynis linked a pull request Mar 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants