mirror of
https://github.com/strongdm/comply
synced 2024-11-22 15:44:55 +00:00
only open html after render is complete during serve
This commit is contained in:
parent
fed98f76e7
commit
7aa267dbb6
@ -9,6 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/skratchdot/open-golang/open"
|
||||||
"github.com/yosssi/ace"
|
"github.com/yosssi/ace"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,6 +30,8 @@ const websocketReloader = `<script>
|
|||||||
</script>`
|
</script>`
|
||||||
|
|
||||||
func html(output string, live bool, errCh chan error, wg *sync.WaitGroup) {
|
func html(output string, live bool, errCh chan error, wg *sync.WaitGroup) {
|
||||||
|
opened := false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
files, err := ioutil.ReadDir(filepath.Join(".", "templates"))
|
files, err := ioutil.ReadDir(filepath.Join(".", "templates"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -77,10 +80,17 @@ func html(output string, live bool, errCh chan error, wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
w.Close()
|
w.Close()
|
||||||
}
|
}
|
||||||
if !live {
|
|
||||||
|
if live {
|
||||||
|
if !opened {
|
||||||
|
opened = true
|
||||||
|
open.Run("output/index.html")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<-subscribe()
|
<-subscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/skratchdot/open-golang/open"
|
|
||||||
"github.com/yosssi/ace"
|
"github.com/yosssi/ace"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -103,10 +102,6 @@ func Build(output string, live bool) error {
|
|||||||
close(wgCh)
|
close(wgCh)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if live {
|
|
||||||
open.Run("output/index.html")
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-wgCh:
|
case <-wgCh:
|
||||||
// success
|
// success
|
||||||
|
Loading…
Reference in New Issue
Block a user