diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dbd20b0..d1c6d636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - The watch feature (via the `--watch` flag) got a few different bug fixes and should be more stable now - ([#423](https://github.com/go-task/task/pull/423)). + ([#423](https://github.com/go-task/task/pull/423), [#365](https://github.com/go-task/task/issues/365)). ## v3.1.0 diff --git a/internal/compiler/compiler.go b/internal/compiler/compiler.go index 43191336..1e0fabfa 100644 --- a/internal/compiler/compiler.go +++ b/internal/compiler/compiler.go @@ -9,4 +9,5 @@ import ( type Compiler interface { GetVariables(t *taskfile.Task, call taskfile.Call) (*taskfile.Vars, error) HandleDynamicVar(v taskfile.Var) (string, error) + ResetCache() } diff --git a/internal/compiler/v2/compiler_v2.go b/internal/compiler/v2/compiler_v2.go index 10af3ce2..5c1d6e46 100644 --- a/internal/compiler/v2/compiler_v2.go +++ b/internal/compiler/v2/compiler_v2.go @@ -109,3 +109,11 @@ func (c *CompilerV2) HandleDynamicVar(v taskfile.Var) (string, error) { return result, nil } + +// ResetCache clear the dymanic variables cache +func (c *CompilerV2) ResetCache() { + c.muDynamicCache.Lock() + defer c.muDynamicCache.Unlock() + + c.dynamicCache = nil +} diff --git a/internal/compiler/v3/compiler_v3.go b/internal/compiler/v3/compiler_v3.go index ae3a8479..0cc9ba78 100644 --- a/internal/compiler/v3/compiler_v3.go +++ b/internal/compiler/v3/compiler_v3.go @@ -96,3 +96,11 @@ func (c *CompilerV3) HandleDynamicVar(v taskfile.Var) (string, error) { return result, nil } + +// ResetCache clear the dymanic variables cache +func (c *CompilerV3) ResetCache() { + c.muDynamicCache.Lock() + defer c.muDynamicCache.Unlock() + + c.dynamicCache = nil +} diff --git a/watch.go b/watch.go index 13c3330a..c14667f6 100644 --- a/watch.go +++ b/watch.go @@ -49,6 +49,9 @@ func (e *Executor) watchTasks(calls ...taskfile.Call) error { cancel() ctx, cancel = context.WithCancel(context.Background()) + + e.Compiler.ResetCache() + for _, c := range calls { c := c go func() {