Skip to content

Commit

Permalink
fix reloaddirs config option
Browse files Browse the repository at this point in the history
  • Loading branch information
atterpac committed Jan 13, 2025
1 parent d638336 commit f90f538
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions v2/cmd/wails/internal/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
}()

// Watch for changes and trigger restartApp()
debugBinaryProcess, err = doWatcherLoop(cwd, buildOptions, debugBinaryProcess, f, exitCodeChannel, quitChannel, f.DevServerURL(), legacyUseDevServerInsteadofCustomScheme)
debugBinaryProcess, err = doWatcherLoop(cwd, projectConfig.ReloadDirectories, buildOptions, debugBinaryProcess, f, exitCodeChannel, quitChannel, f.DevServerURL(), legacyUseDevServerInsteadofCustomScheme)
if err != nil {
return err
}
Expand Down Expand Up @@ -326,9 +326,9 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
}

// doWatcherLoop is the main watch loop that runs while dev is active
func doWatcherLoop(cwd string, buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, error) {
func doWatcherLoop(cwd string, reloadDirs string, buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, error) {
// create the project files watcher
watcher, err := initialiseWatcher(cwd)
watcher, err := initialiseWatcher(cwd, reloadDirs)
if err != nil {
logutils.LogRed("Unable to create filesystem watcher. Reloads will not occur.")
return nil, err
Expand Down
15 changes: 13 additions & 2 deletions v2/cmd/wails/internal/dev/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"os"
"path/filepath"
"strings"

"github.com/wailsapp/wails/v2/internal/fs"

Expand All @@ -17,7 +18,7 @@ type Watcher interface {
}

// initialiseWatcher creates the project directory watcher that will trigger recompile
func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {
func initialiseWatcher(cwd, reloadDirs string) (*fsnotify.Watcher, error) {
// Ignore dot files, node_modules and build directories by default
ignoreDirs := getIgnoreDirs(cwd)

Expand All @@ -27,12 +28,22 @@ func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {
return nil, err
}

customDirs := dirs.AsSlice()
seperatedDirs := strings.Split(reloadDirs, ",")
for _, dir := range seperatedDirs {
customSub, err := fs.GetSubdirectories(filepath.Join(cwd, dir))
if err != nil {
return nil, err
}
customDirs = append(customDirs, customSub.AsSlice()...)
}

watcher, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
}

for _, dir := range processDirectories(dirs.AsSlice(), ignoreDirs) {
for _, dir := range processDirectories(customDirs, ignoreDirs) {
err := watcher.Add(dir)
if err != nil {
return nil, err
Expand Down

0 comments on commit f90f538

Please sign in to comment.