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