Skip to content

Commit 6c59d71

Browse files
committed
Fix handling of cli flag dir.
1 parent 842f04d commit 6c59d71

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
@@ -70,7 +70,10 @@ func (e *Executor) getRootNode() (taskfile.Node, error) {
7070
if err != nil {
7171
return nil, err
7272
}
73-
e.Dir = node.Dir()
73+
if len(e.Dir) == 0 {
74+
// Only set the executor dir if it was not already set (i.e. --dir or --global).
75+
e.Dir = node.Dir()
76+
}
7477
e.Entrypoint = node.Location()
7578
return node, err
7679
}
@@ -219,7 +222,6 @@ func (e *Executor) setupCompiler() error {
219222
return err
220223
}
221224
}
222-
223225
e.Compiler = &Compiler{
224226
Dir: e.Dir,
225227
Entrypoint: e.Entrypoint,

0 commit comments

Comments
 (0)