From 9c475c36e7f39bca76414c46f783fcb427f905d3 Mon Sep 17 00:00:00 2001 From: Marco Molteni Date: Thu, 6 Jun 2019 18:16:09 +0200 Subject: [PATCH] Handle the common case when the task directory is not specified Closes #209 --- task.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/task.go b/task.go index 1e5f430e..9789cf35 100644 --- a/task.go +++ b/task.go @@ -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 + } } }