From 7fa277d875276752f59704b5c40a19f8baed88ea Mon Sep 17 00:00:00 2001 From: juls0730 <62722391+juls0730@users.noreply.github.com> Date: Tue, 19 Nov 2024 02:32:02 -0600 Subject: [PATCH] minor cleanup --- folder/test.go | 1 - main.go | 16 ++++++++++++---- watcher.go | 31 ------------------------------- zqdgr.config.json | 7 ++----- 4 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 folder/test.go diff --git a/folder/test.go b/folder/test.go deleted file mode 100644 index 3b7dc11..0000000 --- a/folder/test.go +++ /dev/null @@ -1 +0,0 @@ -package folder diff --git a/main.go b/main.go index 4801ce8..09aaa9b 100644 --- a/main.go +++ b/main.go @@ -115,8 +115,6 @@ func (s *Script) Stop() error { } func (s *Script) Restart() error { - println("Restarting script") - s.mutex.Lock() s.isRestarting = true @@ -311,10 +309,18 @@ func main() { // iterate over every letter in the pattern for _, p := range config.Pattern { if string(p) == "{" { + if inMatch { + log.Fatal("unmatched { in pattern") + } + inMatch = true } if string(p) == "}" { + if !inMatch { + log.Fatal("unmatched } in pattern") + } + inMatch = false } @@ -328,6 +334,10 @@ func main() { currentPattern += string(p) } + if inMatch { + log.Fatal("unmatched } in pattern") + } + if currentPattern != "" { paternArray = append(paternArray, currentPattern) } @@ -411,6 +421,4 @@ func main() { } script.Wait() - - log.Println("Script finished") } diff --git a/watcher.go b/watcher.go index 6f85c62..27df8da 100644 --- a/watcher.go +++ b/watcher.go @@ -1,14 +1,10 @@ -// There is some dead code in here because I pulled out the parts I needed to get it working, deal with this later lol. - package main import ( "errors" "fmt" "log" - "os" "path/filepath" - "syscall" "github.com/bmatcuk/doublestar" "github.com/fsnotify/fsnotify" @@ -54,7 +50,6 @@ type FileWatcher interface { Close() error AddFiles() error add(path string) error - Watch(jobs chan<- string) getConfig() *WatcherConfig } @@ -71,32 +66,6 @@ func (n NotifyWatcher) AddFiles() error { return addFiles(n) } -func (n NotifyWatcher) Watch(jobs chan<- string) { - for { - select { - case ev := <-n.watcher.Events: - if ev.Op&fsnotify.Remove == fsnotify.Remove || ev.Op&fsnotify.Write == fsnotify.Write || ev.Op&fsnotify.Create == fsnotify.Create { - // Assume it is a directory and track it. - if directoryShouldBeTracked(n.cfg, ev.Name) { - n.watcher.Add(ev.Name) - } - if pathMatches(n.cfg, ev.Name) { - jobs <- ev.Name - } - } - - case err := <-n.watcher.Errors: - if v, ok := err.(*os.SyscallError); ok { - if v.Err == syscall.EINTR { - continue - } - log.Fatal("watcher.Error: SyscallError:", v) - } - log.Fatal("watcher.Error:", err) - } - } -} - func (n NotifyWatcher) add(path string) error { return n.watcher.Add(path) } diff --git a/zqdgr.config.json b/zqdgr.config.json index 76217c9..857242e 100644 --- a/zqdgr.config.json +++ b/zqdgr.config.json @@ -1,6 +1,6 @@ { "name": "zqdgr", - "version": "0.0.1", + "version": "0.0.2", "description": "zqdgr is a quick and dirty Golang runner", "author": "juls0730", "license": "BSL-1.0", @@ -13,8 +13,5 @@ "build": "go build -o zqdgr", "dev": "sleep 5; echo 'test' && sleep 2 && echo 'test2'" }, - "pattern": "**/*.go", - "excluded_dirs": [ - "folder" - ] + "pattern": "**/*.go" } \ No newline at end of file