Files
commerce/util/exec/exec.go
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

35 lines
587 B
Go

package exec
import (
"log"
"os"
"os/exec"
"strings"
"github.com/hanzoai/commerce/config"
)
var conf = config.Get()
func Run(cmd string) {
args := strings.Split(cmd, " ")
cmd, args = args[0], args[1:]
// get old path
oldPath := os.Getenv("PATH")
os.Setenv("PATH", "/usr/local/bin:/usr/bin:/bin")
proc := exec.Command(cmd, args...)
proc.Env = []string{"PATH=/usr/local/bin:/usr/bin:/bin"}
proc.Dir = conf.RootDir
proc.Stdout = os.Stdout
proc.Stderr = os.Stderr
if err := proc.Run(); err != nil {
log.Fatalln(err)
}
// Reset $PATH
os.Setenv("PATH", oldPath)
}