From bfa79a2ef402a612b401072e44f6fea8cfbf1663 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 18 Nov 2017 17:24:51 -0800 Subject: [PATCH] refactor: delegate IsDir decision --- prune.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prune.go b/prune.go index 34cdae6..66a31b8 100644 --- a/prune.go +++ b/prune.go @@ -36,10 +36,6 @@ func (p Pruner) Prune() (*Stats, error) { return err } - if info.IsDir() { - return nil - } - stats.FilesTotal++ if !p.prune(path, info) { @@ -62,6 +58,10 @@ func (p Pruner) Prune() (*Stats, error) { // prune returns true if the file or dir should be pruned. func (p Pruner) prune(path string, info os.FileInfo) bool { + if info.IsDir() { + return false + } + ext := filepath.Ext(path) return ext == ".ts" || ext == ".md" }