Skip to content

Commit 5ea3847

Browse files
committed
improvement and test update
1 parent dd3e271 commit 5ea3847

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

filepath.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,9 @@ func DirsPathExcludes(basePath string, recursive bool, excludes Excludes) (pdirs
281281

282282
if recursive {
283283
err = Walk(basePath, func(srcPath string, info os.FileInfo, err error) error {
284-
if excludes.Match(filepath.Base(srcPath)) {
285-
if info.IsDir() {
286-
// excluding directory
287-
return filepath.SkipDir
288-
}
289-
// excluding file
290-
return nil
284+
if info.IsDir() && excludes.Match(filepath.Base(srcPath)) {
285+
// excluding directory
286+
return filepath.SkipDir
291287
}
292288

293289
if info.IsDir() {
@@ -327,11 +323,7 @@ func FilesPathExcludes(basePath string, recursive bool, excludes Excludes) (file
327323

328324
if recursive {
329325
err = Walk(basePath, func(srcPath string, info os.FileInfo, err error) error {
330-
if excludes.Match(filepath.Base(srcPath)) {
331-
if info.IsDir() {
332-
// excluding directory
333-
return filepath.SkipDir
334-
}
326+
if !info.IsDir() && excludes.Match(filepath.Base(srcPath)) {
335327
// excluding file
336328
return nil
337329
}

0 commit comments

Comments
 (0)