-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.go
59 lines (53 loc) · 1.29 KB
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package dev
import (
"fmt"
"github.com/cryptopunkscc/go-astral-js/pkg/project"
common "github.com/cryptopunkscc/go-astral-js/pkg/wails"
"github.com/wailsapp/wails/v2/pkg/application"
"github.com/wailsapp/wails/v2/pkg/options"
"log"
"os"
"os/signal"
"syscall"
)
func Run(path string, opt *options.App) (err error) {
// Start frontend dev watcher
viteCommand := "npm run dev"
stopDevWatcher, url, _, err := runViteWatcher(viteCommand, path, true)
if err != nil {
return err
}
log.Println("url: ", url)
go func() {
quitChannel := make(chan os.Signal, 1)
signal.Notify(quitChannel, os.Interrupt, syscall.SIGTERM)
<-quitChannel
stopDevWatcher()
}()
// setup opt
front := path
path = path + "/dist"
src, err := project.NewModule(front).PortalNodeModule()
if err != nil {
return err
}
common.SetupOptions(src, opt)
if opt.Title == "" {
opt.Title = "development"
}
titleSuffix := front
if exec, err := os.Getwd(); err == nil {
titleSuffix = exec
}
opt.Title = fmt.Sprintf("%s - %s", opt.Title, titleSuffix)
opt.LogLevel = 6
// Setup dev environment
_ = os.Setenv("devserver", "localhost:34115")
_ = os.Setenv("assetdir", path)
_ = os.Setenv("frontenddevserverurl", url)
// run
log.Println("running wails")
app := application.NewWithOptions(opt)
err = app.Run()
return
}