all repos — vite @ 81b8a3faf63f5b53e9d6e95aa09149941c4a2f11

a fast (this time, actually) and minimal static site generator

util/run.go (view raw)

 1package util
 2
 3import (
 4	"fmt"
 5	"os/exec"
 6	"strings"
 7)
 8
 9func RunCmd(cmd string, args ...string) error {
10	// Split the command into the executable and its arguments
11	parts := strings.Fields(cmd)
12	if len(parts) == 0 {
13		return fmt.Errorf("error: is there an empty command?")
14	}
15
16	execCmd := exec.Command(parts[0], parts[1:]...)
17
18	output, err := execCmd.CombinedOutput()
19	if err != nil {
20		return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output)
21	}
22	return nil
23}