all repos — vite @ 45310dfe7ecd7b5407640287e4e7069a53cf7100

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

util/run.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
package util

import (
	"fmt"
	"os/exec"
	"strings"
)

func RunCmd(cmd string, args ...string) error {
	// Split the command into the executable and its arguments
	parts := strings.Fields(cmd)
	if len(parts) == 0 {
		return fmt.Errorf("error: is there an empty command?")
	}

	execCmd := exec.Command(parts[0], parts[1:]...)

	output, err := execCmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output)
	}
	return nil
}