mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
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
35 lines
587 B
Go
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)
|
|
}
|