Skip to content

Commit

Permalink
fix: handle nested directory watching
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Jul 3, 2023
1 parent 543c20a commit bd4e055
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Alvu struct {

func (al *Alvu) AddFile(file *AlvuFile) {
al.files = append(al.files, file)
al.filesIndex = append(al.filesIndex, file.name)
al.filesIndex = append(al.filesIndex, file.sourcePath)
}

func (al *Alvu) IsAlvuFile(filePath string) bool {
Expand Down Expand Up @@ -259,6 +259,11 @@ func main() {
}

alvuApp.AddFile(alvuFile)

// If serving, also add the nested path into it
if *serveFlag {
watcher.AddDir(path.Dir(alvuFile.sourcePath))
}
}

alvuApp.Build()
Expand Down Expand Up @@ -873,6 +878,13 @@ func NewWatcher(alvu *Alvu) *Watcher {
}

func (w *Watcher) AddDir(dirPath string) {

for _, pth := range w.dirs {
if pth == dirPath {
return
}
}

w.dirs = append(w.dirs, dirPath)
err := w.notify.Add(dirPath)
bail(err)
Expand Down

0 comments on commit bd4e055

Please sign in to comment.