[fix] sui watch command
This commit is contained in:
parent
6d49ae9195
commit
04596d730d
1 changed files with 13 additions and 7 deletions
|
|
@ -68,16 +68,16 @@ var WatchCmd = &cobra.Command{
|
|||
}
|
||||
sui.WithSid(sid)
|
||||
|
||||
tmpl, err := sui.GetTemplate(template)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, color.RedString(err.Error()))
|
||||
return
|
||||
}
|
||||
exitSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(exitSignal, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
|
||||
watchDone := make(chan uint8, 1)
|
||||
|
||||
// -
|
||||
tmpl, err := sui.GetTemplate(template)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, color.RedString(err.Error()))
|
||||
return
|
||||
}
|
||||
root := filepath.Join(cfg.DataRoot, tmpl.GetRoot())
|
||||
publicRoot, err := sui.PublicRootWithSid(sid)
|
||||
assetRoot := filepath.Join(publicRoot, "assets")
|
||||
|
|
@ -89,9 +89,15 @@ var WatchCmd = &cobra.Command{
|
|||
go watch(root, func(event, name string) {
|
||||
if event == "WRITE" || event == "CREATE" || event == "RENAME" {
|
||||
// @Todo build single page and sync single asset file to public
|
||||
|
||||
fmt.Printf(color.WhiteString("Building... "))
|
||||
err := tmpl.Build(&core.BuildOption{SSR: true, AssetRoot: assetRoot})
|
||||
|
||||
tmpl, err := sui.GetTemplate(template)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, color.RedString(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
err = tmpl.Build(&core.BuildOption{SSR: true, AssetRoot: assetRoot})
|
||||
if err != nil {
|
||||
fmt.Fprint(os.Stderr, color.RedString(fmt.Sprintf("Failed: %s\n", err.Error())))
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue