Open deepbrook opened 1 year ago
Any update on this?
So this is closest to the problem I'm experiencing.
Including a task file does change the working directory.
It is not a problem since I created a variable for my PROJECT_DIR
PROJECT_DIR:
sh: "git rev-parse --show-toplevel"
Here is my example using your examples:
# test/Taskfile.yaml
---
version: 3
vars:
PROJECT_DIR:
sh: pwd
includes:
foo:
taskfile: lib/foo.yaml
dir: ./
tasks:
pwd:
cmds:
- echo $PWD
toplevel:foo-bar-pwd:
cmds:
- task: foo:bar:pwd
- task: foo:bar:pwd:root
# No change to this file
# test/lib/foo.yaml
---
version: 3
includes:
bar:
taskfile: ./bar.yaml
dir: ./
tasks:
pwd:
cmds:
- echo $PWD
foolevel:bar-pwd:
cmds:
- task: bar:root
# test/lib/bar.yaml
---
version: 3
tasks:
pwd:
dir: "{{ .PROJECT_DIR }}"
cmds:
- echo $PWD
pwd:root:
dir: "/{{ .PROJECT_DIR }}"
cmds:
- echo $PWD
I just want you to see the bar file where I added explicit directories to the tasks
Notice that the pwd:root
has a preceding slash for the directory
{{.PROJECT_DIR}}
in this case is dynamically set in the Taskfile.yaml
the output is this
task toplevel:foo-bar-pwd
task: [foo:bar:pwd] echo $PWD
/task_bug/lib/task_bug
task: [foo:bar:pwd:root] echo $PWD
/task_bug
Not sure why you would need to specify the extra / my guess is they are linked somehow
Given the following Taskfiles:
We get the following behaviour when calling the above tasks:
IMO, this is unexpected behaviour and a bug - as I'm calling all tasks from
test/Taskfile.yaml
, which specifically declares the exec directory should be./
for the included taskfiles.In otherwords, the correct behaviour should be as follows if running
foo.yaml
in thelib
directory:tl;dr: It looks like the value of
dir
is dependent on the location of task being called within the taskfiles includes tree, instead of being correctly merged/updated with the parent taskfile'sdir
when recursing into the included files.Task Version