mirror of
https://github.com/facundoolano/jorge.git
synced 2024-12-25 21:58:28 +01:00
move dotfile check
This commit is contained in:
parent
f43b0cdb60
commit
1878db2fc8
2 changed files with 7 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue