Skip to content

Commit 4ccae15

Browse files
committed
Fix handling of cli flag dir.
1 parent c62f9c7 commit 4ccae15

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

internal/flags/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ func (o *flagsOption) ApplyToExecutor(e *task.Executor) {
275275
if err == nil {
276276
dir = home
277277
}
278+
} else {
279+
if len(dir) > 0 {
280+
// Use the cli provided directory.
281+
cwd, _ := os.Getwd()
282+
dir = filepath.Join(cwd, dir)
283+
}
278284
}
279285

280286
e.Options(

setup.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ func (e *Executor) getRootNode() (taskfile.Node, error) {
6767
if err != nil {
6868
return nil, err
6969
}
70-
e.Dir = node.Dir()
70+
if len(e.Dir) == 0 {
71+
// Only set the executor dir if it was not already set (i.e. --dir or --global).
72+
e.Dir = node.Dir()
73+
}
7174
e.Entrypoint = node.Location()
7275
return node, err
7376
}
@@ -216,7 +219,6 @@ func (e *Executor) setupCompiler() error {
216219
return err
217220
}
218221
}
219-
220222
e.Compiler = &Compiler{
221223
Dir: e.Dir,
222224
Entrypoint: e.Entrypoint,

0 commit comments

Comments
 (0)