Skip to content

Commit f90f538

Browse files
committed
fix reloaddirs config option
1 parent d638336 commit f90f538

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

v2/cmd/wails/internal/dev/dev.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
153153
}()
154154

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

328328
// doWatcherLoop is the main watch loop that runs while dev is active
329-
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) {
329+
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) {
330330
// create the project files watcher
331-
watcher, err := initialiseWatcher(cwd)
331+
watcher, err := initialiseWatcher(cwd, reloadDirs)
332332
if err != nil {
333333
logutils.LogRed("Unable to create filesystem watcher. Reloads will not occur.")
334334
return nil, err

v2/cmd/wails/internal/dev/watcher.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"os"
66
"path/filepath"
7+
"strings"
78

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

@@ -17,7 +18,7 @@ type Watcher interface {
1718
}
1819

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

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

31+
customDirs := dirs.AsSlice()
32+
seperatedDirs := strings.Split(reloadDirs, ",")
33+
for _, dir := range seperatedDirs {
34+
customSub, err := fs.GetSubdirectories(filepath.Join(cwd, dir))
35+
if err != nil {
36+
return nil, err
37+
}
38+
customDirs = append(customDirs, customSub.AsSlice()...)
39+
}
40+
3041
watcher, err := fsnotify.NewWatcher()
3142
if err != nil {
3243
return nil, err
3344
}
3445

35-
for _, dir := range processDirectories(dirs.AsSlice(), ignoreDirs) {
46+
for _, dir := range processDirectories(customDirs, ignoreDirs) {
3647
err := watcher.Add(dir)
3748
if err != nil {
3849
return nil, err

0 commit comments

Comments
 (0)