Skip to content

Commit daa4f1f

Browse files
committed
Fixed issue with incorrect 'test' path matching which could e.g. remove a folder called 'testimonials'
1 parent 63133f9 commit daa4f1f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

utils.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ func IsInTestFolder(path string, testsPath string) bool {
6262
return IsCommonTestFolder(path)
6363
}
6464

65-
if strings.Contains(path, string(os.PathSeparator)+testsPath) {
65+
// At this point, `testsPath` may have a value like this: "sample-node-project/test".
66+
// Thus, we want to do 2 things:
67+
// - Exclude this folder itself, i.e. check for a path that ends with "sample-node-project/test"
68+
// - Exclude any file in it, i.e. check for path that contains "sample-node-project/test/"
69+
fileInTestFolderPath := testsPath + string(os.PathSeparator)
70+
71+
if strings.HasSuffix(path, testsPath) || strings.Contains(path, fileInTestFolderPath) {
6672
if !didPrintTestsMsg {
6773
log.Info("\tIgnoring the entire content of the `" + testsPath + "` folder (contains test files)")
6874
didPrintTestsMsg = true

0 commit comments

Comments
 (0)