Update pkg/tools/browser.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
danieldd 2026-02-16 20:35:18 +07:00 committed by GitHub
parent 29e8319cfd
commit c953c1629d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,22 +11,31 @@ import (
"fmt" "fmt"
"os/exec" "os/exec"
"strings" "strings"
"sync"
"time" "time"
) )
// actionbookBinary caches the resolved path to the actionbook CLI. // actionbookBinary caches the resolved path to the actionbook CLI.
var actionbookBinary string var (
actionbookBinary string
actionbookOnce sync.Once
actionbookErr error
)
func resolveActionbook() (string, error) { func resolveActionbook() (string, error) {
if actionbookBinary != "" { actionbookOnce.Do(func() {
return actionbookBinary, nil var path string
path, actionbookErr = exec.LookPath("actionbook")
if actionbookErr != nil {
actionbookErr = fmt.Errorf("actionbook CLI not found in PATH: %w", actionbookErr)
return
}
actionbookBinary = path
})
if actionbookErr != nil {
return "", actionbookErr
} }
path, err := exec.LookPath("actionbook") return actionbookBinary, nil
if err != nil {
return "", fmt.Errorf("actionbook CLI not found in PATH: %w", err)
}
actionbookBinary = path
return path, nil
} }
// runActionbook executes an actionbook CLI command with a timeout. // runActionbook executes an actionbook CLI command with a timeout.