Skip to content

Commit 4ab1ab2

Browse files
andreyneringjaynis
andcommitted
fix: .USER_WORKING_DIR should contain the value of --dir if given
Closes #2102 Closes #2103 Co-authored-by: jaynis <[email protected]>
1 parent e65159f commit 4ab1ab2

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

executor.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"io"
66
"os"
7+
"path/filepath"
78
"sync"
89
"time"
910

@@ -121,6 +122,7 @@ type dirOption struct {
121122
}
122123

123124
func (o *dirOption) ApplyToExecutor(e *Executor) {
125+
e.UserWorkingDir, _ = filepath.Abs(o.dir)
124126
e.Dir = o.dir
125127
}
126128

task_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ func TestUserWorkingDirectory(t *testing.T) {
21482148

21492149
var buff bytes.Buffer
21502150
e := task.NewExecutor(
2151-
task.WithDir("testdata/user_working_dir"),
2151+
task.WithEntrypoint("testdata/user_working_dir/Taskfile.yml"),
21522152
task.WithStdout(&buff),
21532153
task.WithStderr(&buff),
21542154
)

website/docs/reference/templating.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ special variable will be overridden.
115115
| `TASKFILE` | The absolute path of the included Taskfile. |
116116
| `TASKFILE_DIR` | The absolute path of the included Taskfile directory. |
117117
| `TASK_DIR` | The absolute path of the directory where the task is executed. |
118-
| `USER_WORKING_DIR` | The absolute path of the directory `task` was called from. |
118+
| `USER_WORKING_DIR` | The absolute path of the directory `task` was called from, or the value of `--dir` (`-d`) if given. |
119119
| `CHECKSUM` | The checksum of the files listed in `sources`. Only available within the `status` prop and if method is set to `checksum`. |
120120
| `TIMESTAMP` | The date object of the greatest timestamp of the files listed in `sources`. Only available within the `status` prop and if method is set to `timestamp`. |
121121
| `TASK_VERSION` | The current version of task. |

website/docs/usage.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ In this example, we can run `cd <service>` and `task up` and as long as the
6161
`<service>` directory contains a `docker-compose.yml`, the Docker composition
6262
will be brought up.
6363

64+
:::info
65+
66+
`.USER_WORKING_DIR` will contain the value of the `--dir` (`-d`) flag, if given.
67+
68+
:::
69+
6470
### Running a global Taskfile
6571

6672
If you call Task with the `--global` (alias `-g`) flag, it will look for your

0 commit comments

Comments
 (0)