1
0
mirror of https://github.com/go-task/task.git synced 2025-03-21 21:27:07 +02:00

Handle the common case when the task directory is not specified

Closes #209
This commit is contained in:
Marco Molteni 2019-06-06 18:16:09 +02:00
parent c663c5c507
commit 9c475c36e7

12
task.go
View File

@ -200,12 +200,14 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error {
}
}
// When using the dir: attribute it can happen that the directory doesn't exist.
// When using the "dir:" attribute it can happen that the directory doesn't exist.
// If so, we create it.
if _, err := os.Stat(t.Dir); os.IsNotExist(err) {
if err := os.MkdirAll(t.Dir, 0755); err != nil {
e.Logger.Errf("cannot make directory %v: %v", t.Dir, err)
return err
if t.Dir != "" {
if _, err := os.Stat(t.Dir); os.IsNotExist(err) {
if err := os.MkdirAll(t.Dir, 0755); err != nil {
e.Logger.Errf("task: cannot make directory %q: %v", t.Dir, err)
return err
}
}
}