watch pb_hooks subdirectories

This commit is contained in:
Gani Georgiev 2023-07-23 23:45:33 +03:00
parent 085fb1601e
commit edcb6950e5
2 changed files with 16 additions and 5 deletions

View File

@ -108,6 +108,8 @@
If `?skipTotal=1` is set, the response fields `totalItems` and `totalPages` will have `-1` value (this is to avoid having different JSON responses and to differentiate from the zero default).
With the latest JS SDK 0.16+ and Dart SDK v0.11+ versions `skipTotal=1` is set by default for the `getFirstListItem()` and `getFullList()` requests.
- Added new utility `github.com/pocketbase/pocketbase/tools/template` package to assist with rendering HTML templates using the standard Go `html/template` and `text/template` syntax.
## v0.16.10

View File

@ -16,6 +16,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"strings"
"time"
"github.com/dop251/goja"
@ -342,14 +343,22 @@ func (p *plugin) watchHooks() error {
}
}()
// add the directory to watch
err = watcher.Add(p.config.HooksDir)
if err != nil {
watcher.Close()
return err
// add directories to watch
//
// @todo replace once recursive watcher is added (https://github.com/fsnotify/fsnotify/issues/18)
dirsErr := filepath.Walk(p.config.HooksDir, func(path string, info fs.FileInfo, err error) error {
// ignore hidden directories and node_modules
if !info.IsDir() || info.Name() == "node_modules" || strings.HasPrefix(info.Name(), ".") {
return nil
}
return nil
return watcher.Add(path)
})
if dirsErr != nil {
watcher.Close()
}
return dirsErr
}
// fullTypesPathReturns returns the full path to the generated TS file.