From 7021e4041bbfb469797f78572a9432f3c93b171f Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 20 Oct 2024 19:46:06 +0200 Subject: Provide a list of extensions --- main.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index a783bef..0888e93 100644 --- a/main.go +++ b/main.go @@ -40,14 +40,23 @@ var ( BuildCommand []string // Command run after build RunCommand []string - // Command will only run on files that have the Ext extension - Ext string + // Command will only run on files that have the Extensions extension + Extensions []string +) + const ( DateLayout string = "15:04:05" ) func CompileRun(fileName string) { - if !strings.HasSuffix(fileName, Ext) { + found := false + for _, Ext := range Extensions { + if strings.HasSuffix(fileName, Ext) { + found = true + break + } + } + if !found { return } @@ -129,7 +138,7 @@ func main() { BuildCommand = strings.Split(*bc, " ") RunCommand = strings.Split(*rc, " ") - Ext = *e + Extensions = strings.Split(*e, ",") Path = *p fmt.Printf("[%s watching '%s'%s]\n", Cyan, Path, Reset) -- cgit v1.2.3