Skip to content

Commit

Permalink
fix: fix browser open
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Aug 23, 2022
1 parent 5295624 commit 5079630
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/core/god/daemonproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,21 @@ func (daemonProc *daemonProcess) startIntl(name string) error {
daemonProc.reg[index] = koiProc

koiProc.Register(do.MustInvoke[*logger.KoiFileTarget](daemonProc.i))
koiProc.HookOutput = func(msg string) {
go func() {
if strings.Contains(msg, " server listening at ") {
s := msg[strings.Index(msg, "http"):] //nolint:gocritic
s = s[:strings.Index(s, strutil.ColorStartCtr)] //nolint:gocritic
l.Debugf("Parsed %s. Try opening browser.", s)
err := browser.OpenURL(s)
if err != nil {
l.Warnf("cannot open browser: %s", err.Error())

if cfg.Data.Open {
koiProc.HookOutput = func(msg string) {
go func() {
if strings.Contains(msg, " server listening at ") {
s := msg[strings.Index(msg, "http"):] //nolint:gocritic
s = s[:strings.Index(s, strutil.ColorStartCtr)] //nolint:gocritic
l.Debugf("Parsed %s. Try opening browser.", s)
err := browser.OpenURL(s)
if err != nil {
l.Warnf("cannot open browser: %s", err.Error())
}
}
}
}()
}()
}
}

daemonProc.wg.Add(1)
Expand Down

0 comments on commit 5079630

Please sign in to comment.