|
|
|
|
@ -7,22 +7,32 @@ import ( |
|
|
|
|
"io" |
|
|
|
|
"os" |
|
|
|
|
"time" |
|
|
|
|
"slices" |
|
|
|
|
"regexp" |
|
|
|
|
"io/fs" |
|
|
|
|
"path/filepath" |
|
|
|
|
"errors" |
|
|
|
|
"lcthw.dev/go/ttarpit/config" |
|
|
|
|
"github.com/fsnotify/fsnotify" |
|
|
|
|
"bufio" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func LaunchLogger(in io.Reader, out io.Writer, err error) { |
|
|
|
|
if err != nil { log.Fatal(err) } |
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
if _, err := io.Copy(out, in) |
|
|
|
|
scan := bufio.NewScanner(in) |
|
|
|
|
|
|
|
|
|
err != nil { log.Printf("LOGGER: %v", err) } |
|
|
|
|
for scan.Scan() { |
|
|
|
|
for _, reg := range config.Settings.TriggerRegex { |
|
|
|
|
line := scan.Text() |
|
|
|
|
|
|
|
|
|
matches := reg.FindStringSubmatch(line) |
|
|
|
|
if len(matches) > 0 { |
|
|
|
|
file, line, col, err_type, text := matches[1], matches[2], matches[3], matches[4], matches[5] |
|
|
|
|
fmt.Printf("!!!!!!!!!!!!!! file=%s, line=%s, col=%s, type=%s, text=%s\n",
|
|
|
|
|
file, line, col, err_type, text) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -49,7 +59,6 @@ func LaunchProcess(proc *config.Process) { |
|
|
|
|
|
|
|
|
|
fmt.Println("SENDING READY on channel") |
|
|
|
|
|
|
|
|
|
fmt.Println("SENT READY") |
|
|
|
|
proc.ExecCmd.Wait() |
|
|
|
|
fmt.Println("PROCESS", proc.Command, "EXITED") |
|
|
|
|
} |
|
|
|
|
@ -57,17 +66,15 @@ func LaunchProcess(proc *config.Process) { |
|
|
|
|
func MatchesPath(fp string) bool { |
|
|
|
|
fp = filepath.ToSlash(fp) |
|
|
|
|
|
|
|
|
|
is_included := slices.ContainsFunc(config.Settings.Includes, func (reg string) bool { |
|
|
|
|
matches, err := regexp.MatchString(reg, fp) |
|
|
|
|
for _, reg := range config.Settings.IncludeRegex { |
|
|
|
|
matches := reg.MatchString(fp) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
log.Panic("invalid excludes regex", reg, "error: ", err) |
|
|
|
|
if matches { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return matches |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return is_included |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func RunBuild() { |
|
|
|
|
|