Skip to content

Commit

Permalink
dynamic refresh config
Browse files Browse the repository at this point in the history
  • Loading branch information
atterpac committed Jan 19, 2024
1 parent aea6028 commit 95ad933
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
13 changes: 10 additions & 3 deletions v3/internal/commands/watcher.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package commands

import (
"log/slog"
"os"
"path/filepath"
"runtime"
"strings"

Expand All @@ -19,10 +19,10 @@ const (
linuxExtension = ""
darwinExtension = ".app"

appVar = "<WAILS_APP_NAME>"
extensionVar = "<OS_EXTENSION>"
)


func Watcher(options *WatcherOptions) error {
stopChan := make(chan struct{})
watcherEngine := engine.Engine{}
Expand Down Expand Up @@ -68,7 +68,14 @@ func parseConfig(config string) (string, error) {
case "darwin":
ext = darwinExtension
}
// Replace extension
stringConfig := strings.ReplaceAll(string(byteConfig), extensionVar, ext)
slog.Warn(stringConfig)
projectName, err := os.Getwd()
if err != nil {
return "", err
}
// Replace app name with init project name
projectName = filepath.Base(projectName)
stringConfig = strings.ReplaceAll(stringConfig, appVar, projectName)
return stringConfig, nil
}
23 changes: 23 additions & 0 deletions v3/internal/templates/_base/default/build/devmode.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
config:
root_path: ..
log_level: info
debounce: 1000
ignore:
dir:
- frontend
file:
- .gitignore
watched_extension:
- '*.go'
git_ignore: true
background:
cmd: 'wails3 task dev:frontend'
executes:
- cmd: go mod tidy
blocking: true
- cmd: wails3 task build
blocking: true
- cmd: KILL_STALE
- cmd: ./bin/<WAILS_APP_NAME><OS_EXTENSION>
primary: true

0 comments on commit 95ad933

Please sign in to comment.