move dotfile check

This commit is contained in:
facundoolano 2024-02-15 15:25:44 -03:00
parent f43b0cdb60
commit 1878db2fc8
2 changed files with 7 additions and 8 deletions

View file

@ -6,7 +6,6 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/facundoolano/blorg/site" "github.com/facundoolano/blorg/site"
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"
@ -81,13 +80,7 @@ func setupWatcher() (*fsnotify.Watcher, error) {
} }
// chmod events are noisy, ignore them // chmod events are noisy, ignore them
isChmod := event.Has(fsnotify.Chmod) if 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 {
fmt.Printf("\nFile %s changed, triggering rebuild.\n", event.Name) 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 // since new nested directories could be triggering this change, and we need to watch those too

View file

@ -84,6 +84,12 @@ func (site *Site) loadTemplates(srcDir string) error {
err = filepath.WalkDir(srcDir, func(path string, entry fs.DirEntry, err error) error { err = filepath.WalkDir(srcDir, func(path string, entry fs.DirEntry, err error) error {
if !entry.IsDir() { 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) templ, err := templates.Parse(site.templateEngine, path)
// if sometime fails or this is not a template, skip // if sometime fails or this is not a template, skip
if err != nil || templ == nil { if err != nil || templ == nil {