fix(process): ensure program paths are absolute

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-03-31 19:56:13 +00:00
parent cd16b014da
commit 3a60b9f1e7
2 changed files with 9 additions and 0 deletions

View file

@ -3,6 +3,7 @@ package process
import (
"bytes"
"context"
"path/filepath"
"strconv"
"dappco.re/go/core"
@ -36,6 +37,12 @@ func (p *Program) Find() error {
if err != nil {
return core.E("program.find", core.Concat(strconv.Quote(p.Name), ": not found in PATH"), ErrProgramNotFound)
}
if !filepath.IsAbs(path) {
path, err = filepath.Abs(path)
if err != nil {
return core.E("program.find", core.Concat(strconv.Quote(p.Name), ": failed to resolve absolute path"), err)
}
}
p.Path = path
return nil
}

View file

@ -3,6 +3,7 @@ package process_test
import (
"context"
"os"
"path/filepath"
"testing"
"time"
@ -24,6 +25,7 @@ func TestProgram_Find_Good(t *testing.T) {
p := &process.Program{Name: "echo"}
require.NoError(t, p.Find())
assert.NotEmpty(t, p.Path)
assert.True(t, filepath.IsAbs(p.Path))
}
func TestProgram_FindUnknown_Bad(t *testing.T) {