From 1878db2fc84342ac0ae9a44f6da77d6b2f9e2309 Mon Sep 17 00:00:00 2001 From: facundoolano Date: Thu, 15 Feb 2024 15:25:44 -0300 Subject: [PATCH] move dotfile check --- commands/serve.go | 9 +-------- site/site.go | 6 ++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/commands/serve.go b/commands/serve.go index 1572e77..d9009f9 100644 --- a/commands/serve.go +++ b/commands/serve.go @@ -6,7 +6,6 @@ import ( "net/http" "os" "path/filepath" - "strings" "github.com/facundoolano/blorg/site" "github.com/fsnotify/fsnotify" @@ -81,13 +80,7 @@ func setupWatcher() (*fsnotify.Watcher, error) { } // chmod events are noisy, ignore them - isChmod := event.Has(fsnotify.Chmod) - - // I've seen issues with temporary files, eg. .#name.org generated by emacs - // I'll just ignore changes to dotfiles to stay on the safe side - isDotFile := strings.HasPrefix(filepath.Base(event.Name), ".") - - if !isChmod && !isDotFile { + if event.Has(fsnotify.Chmod) { fmt.Printf("\nFile %s changed, triggering rebuild.\n", event.Name) // since new nested directories could be triggering this change, and we need to watch those too diff --git a/site/site.go b/site/site.go index f00fcaa..79deafa 100644 --- a/site/site.go +++ b/site/site.go @@ -84,6 +84,12 @@ func (site *Site) loadTemplates(srcDir string) error { err = filepath.WalkDir(srcDir, func(path string, entry fs.DirEntry, err error) error { if !entry.IsDir() { + // I've seen issues with temporary files, eg. .#name.org generated by emacs + // I'll just ignore changes to dotfiles to stay on the safe side + if strings.HasPrefix(filepath.Base(path), ".") { + return nil + } + templ, err := templates.Parse(site.templateEngine, path) // if sometime fails or this is not a template, skip if err != nil || templ == nil {