minor cleanup

This commit is contained in:
Zoe
2024-11-19 02:32:02 -06:00
parent b078e54000
commit 7fa277d875
4 changed files with 14 additions and 41 deletions

View File

@@ -1 +0,0 @@
package folder

16
main.go
View File

@@ -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")
}

View File

@@ -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)
}

View File

@@ -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"
}