Update pkg/tools/browser.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
29e8319cfd
commit
c953c1629d
1 changed files with 18 additions and 9 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue