-
-
Notifications
You must be signed in to change notification settings - Fork 669
Add special variable for task working directory #2102
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
Comments
I was running into something similar when I came across this. Upon further study, I think Observe. With this Taskfile.yml and an empty subdir:
% task % task --dir subdir % (cd subdir; task) Now create
Now:
So it seems that |
In case I'm right, see #2123. |
Hi @jberkenbilt . Thank you for your detailed response. I think you are indeed right, but I dont see how your observation is different from mine. Maybe it is just wording. So my understanding is was/is:
All I wanted to achieve is to have a special variable which contains the path which has been set with |
Oh, @jaynis, I see. I guess there are really three different things. Suppose you have this Taskfile:
and this directory structure:
If you are in /tmp/z/a/b/c and run
Your first comment says you don't see much of a use case for knowing where task was started from when run with I still think the problem is that Anyway, I don't think what I'm saying contradicts what you're saying; I'm just adding the nuance that I think, regardless of whether the feature you want is there, the documentation for Anyway, I'm new here -- I just started playing with taskfile today and don't have any connection with the project. :-) |
Well, as you must have noticed in your PR, strictly speaking the I agree that having a variable which contains the directory from which task has been called from ( |
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 parameterand
TASK_DIR
which merely contains what has been configured underdir:
in a task of theTaskfile.yml
file and does not even resolve template expressions.I see two different solutions to this problem:
Either change the behavior ofUSER_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
TASK_WORKING_DIR
which contains the desired dir and does not break the current behavior ofUSER_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 haveTaskfiles.yml
files. I now want to reuse the logic of theTaskfile.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 asUSER_WORKING_DIR
still contains the root directory as outlined above.The text was updated successfully, but these errors were encountered: