๐Ÿ“ฆ pengsrc / docker-tools

๐Ÿ“„ command.go ยท 20 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20package build

import (
	"os/exec"
)

// CommandExists checks whether a command exists.
func CommandExists(command string) (isExists bool) {
	cmd := exec.Command("which", command)
	out, err := cmd.Output()
	if err != nil {
		return
	}

	if len(out) > 0 {
		isExists = true
	}
	return
}