watch includes and datafile dirs

This commit is contained in:
facundoolano 2024-02-15 17:01:14 -03:00
parent 0906b1ef45
commit 01d690b31d
2 changed files with 3 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import (
const SRC_DIR = "src" const SRC_DIR = "src"
const TARGET_DIR = "target" const TARGET_DIR = "target"
const LAYOUTS_DIR = "layouts" const LAYOUTS_DIR = "layouts"
const INCLUDES_DIR = "includes"
const DATA_DIR = "data" const DATA_DIR = "data"
func Init() error { func Init() error {

View file

@ -113,6 +113,8 @@ func setupWatcher() (*fsnotify.Watcher, error) {
// Add the layouts and all source directories to the given watcher // Add the layouts and all source directories to the given watcher
func addAll(watcher *fsnotify.Watcher) error { func addAll(watcher *fsnotify.Watcher) error {
err := watcher.Add(LAYOUTS_DIR) err := watcher.Add(LAYOUTS_DIR)
err = watcher.Add(DATA_DIR)
err = watcher.Add(INCLUDES_DIR)
// fsnotify watches all files within a dir, but non recursively // fsnotify watches all files within a dir, but non recursively
// this walks through the src dir and adds watches for each found directory // this walks through the src dir and adds watches for each found directory
filepath.WalkDir(SRC_DIR, func(path string, entry fs.DirEntry, err error) error { filepath.WalkDir(SRC_DIR, func(path string, entry fs.DirEntry, err error) error {