Compare commits
No commits in common. "ea1d5ea911c25259e05d0d3d66fc4fbd8c1c9f72" and "2bd82e1981ce4e52e54e96235c73ad0fd6da1bb1" have entirely different histories.
ea1d5ea911
...
2bd82e1981
54
main.go
54
main.go
@ -22,8 +22,7 @@ var triggerReload = make(chan struct{})
|
|||||||
type options struct {
|
type options struct {
|
||||||
ESBuild api.BuildOptions
|
ESBuild api.BuildOptions
|
||||||
Watch struct {
|
Watch struct {
|
||||||
Path string
|
Path string
|
||||||
Exclude []string
|
|
||||||
}
|
}
|
||||||
Copy []struct {
|
Copy []struct {
|
||||||
Src string
|
Src string
|
||||||
@ -32,34 +31,26 @@ type options struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flow := &goyek.Flow{}
|
|
||||||
opts := options{}
|
opts := options{}
|
||||||
|
cfgContent, err := os.ReadFile("./.gowebbuild.json")
|
||||||
|
|
||||||
cfgPathParam := flow.RegisterStringParam(goyek.StringParam{
|
if err != nil {
|
||||||
Name: "c",
|
fmt.Printf("%+v\n", err)
|
||||||
Usage: "Path to config file config file.",
|
os.Exit(1)
|
||||||
Default: "./.gowebbuild.json",
|
}
|
||||||
})
|
|
||||||
|
|
||||||
watchFrontend := goyek.Task{
|
err = json.Unmarshal(cfgContent, &opts)
|
||||||
Name: "watch-frontend",
|
if err != nil {
|
||||||
Usage: "",
|
fmt.Printf("%+v\n", err)
|
||||||
Params: goyek.Params{cfgPathParam},
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
flow := &goyek.Flow{}
|
||||||
|
|
||||||
|
flow.Register(goyek.Task{
|
||||||
|
Name: "watch-frontend",
|
||||||
|
Usage: "",
|
||||||
Action: func(tf *goyek.TF) {
|
Action: func(tf *goyek.TF) {
|
||||||
cfgPath := cfgPathParam.Get(tf)
|
|
||||||
cfgContent, err := os.ReadFile(cfgPath)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%+v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(cfgContent, &opts)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%+v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
@ -69,11 +60,6 @@ func main() {
|
|||||||
w := watcher.New()
|
w := watcher.New()
|
||||||
w.SetMaxEvents(1)
|
w.SetMaxEvents(1)
|
||||||
w.FilterOps(watcher.Write, watcher.Rename, watcher.Move, watcher.Create, watcher.Remove)
|
w.FilterOps(watcher.Write, watcher.Rename, watcher.Move, watcher.Create, watcher.Remove)
|
||||||
|
|
||||||
if len(opts.Watch.Exclude) > 0 {
|
|
||||||
w.Ignore(opts.Watch.Exclude...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := w.AddRecursive(opts.Watch.Path); err != nil {
|
if err := w.AddRecursive(opts.Watch.Path); err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -96,9 +82,6 @@ func main() {
|
|||||||
|
|
||||||
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Path)
|
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Path)
|
||||||
|
|
||||||
cp(opts)
|
|
||||||
build(opts)
|
|
||||||
|
|
||||||
if err := w.Start(time.Millisecond * 100); err != nil {
|
if err := w.Start(time.Millisecond * 100); err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
@ -125,9 +108,8 @@ func main() {
|
|||||||
fmt.Println("\nExit")
|
fmt.Println("\nExit")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
|
|
||||||
flow.DefaultTask = flow.Register(watchFrontend)
|
|
||||||
flow.Main()
|
flow.Main()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Watch": {
|
"Watch": {
|
||||||
"Path": "./frontend/src",
|
"Path": "./frontend/src"
|
||||||
"Exclude": [ "./dist" ]
|
|
||||||
},
|
},
|
||||||
"Copy": [
|
"Copy": [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user