Ensure scripting command watched only JS files

This commit is contained in:
Alon Girmonsky
2024-10-08 10:04:46 -07:00
parent 783aa03b6a
commit 3fcc51c5c3
2 changed files with 10 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"context"
"encoding/json"
"strings"
"github.com/creasty/defaults"
"github.com/fsnotify/fsnotify"
@@ -168,6 +169,10 @@ func watchScripts(provider *kubernetes.Provider, block bool) {
select {
// watch for events
case event := <-watcher.Events:
if !strings.HasSuffix(event.Name, "js") {
log.Info().Str("file", event.Name).Msg("Ignoring file")
continue
}
switch event.Op {
case fsnotify.Create:
script, err := misc.ReadScriptFile(event.Name)