mirror of
https://github.com/go-task/task.git
synced 2025-04-19 12:12:27 +02:00
fix: exclude other "ignored" files. (#1356)
This commit is contained in:
parent
a70f5aafc2
commit
2f92f2ac5f
14
watch.go
14
watch.go
@ -176,6 +176,16 @@ func (e *Executor) registerWatchedFiles(w *watcher.Watcher, calls ...taskfile.Ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
func shouldIgnoreFile(path string) bool {
|
func shouldIgnoreFile(path string) bool {
|
||||||
return strings.Contains(path, "/.git") || strings.Contains(path, "/.hg") ||
|
ignorePaths := []string{
|
||||||
strings.Contains(path, "/.task") || strings.Contains(path, "/node_modules")
|
"/.task",
|
||||||
|
"/.git",
|
||||||
|
"/.hg",
|
||||||
|
"/.node_modules",
|
||||||
|
}
|
||||||
|
for _, p := range ignorePaths {
|
||||||
|
if strings.Contains(path, fmt.Sprintf("%s/", p)) || strings.HasSuffix(path, p) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package task_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -79,3 +80,21 @@ Hello, World!
|
|||||||
err = os.RemoveAll(filepathext.SmartJoin(dir, "src"))
|
err = os.RemoveAll(filepathext.SmartJoin(dir, "src"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShouldIgnoreFile(t *testing.T) {
|
||||||
|
tt := []struct {
|
||||||
|
path string
|
||||||
|
expect bool
|
||||||
|
}{
|
||||||
|
{"/.git/hooks", true},
|
||||||
|
{"/.github/workflows/build.yaml", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, ct := range tt {
|
||||||
|
ct := ct
|
||||||
|
t.Run(fmt.Sprintf("ignore - %d", k), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require.Equal(t, shouldIgnoreFile(ct.path), ct.expect)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user