From 69ab70821abc708cef4361fdc522a7352bed7ad7 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sat, 19 Jan 2019 17:26:51 -0200 Subject: [PATCH] Apply logic to ignore invalid extensions for non glob matches --- watcher.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/watcher.go b/watcher.go index 5abbf6d..a711480 100644 --- a/watcher.go +++ b/watcher.go @@ -189,11 +189,12 @@ func resolvePaths(paths []string, extensions map[string]bool) (map[string]bool, } for _, match := range matches { - // don't care for extension filter right now for non glob paths - // since they could be a directory - if isGlob { - if _, ok := extensions[filepath.Ext(match)]; !ok { - continue + // ignore existing files that don't match the allowed extensions + if f, err := os.Stat(match); !os.IsNotExist(err) && !f.IsDir() { + if ext := filepath.Ext(match); ext != "" { + if _, ok := extensions[ext]; !ok { + continue + } } }