0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-28 18:20:35 +00:00
wp-git-action/plugin/utils.go

34 lines
516 B
Go
Raw Normal View History

2022-11-27 13:33:39 +00:00
package plugin
2019-06-07 10:32:16 +00:00
import (
"fmt"
"io"
"os"
"os/exec"
"strings"
)
// helper function to simply wrap os execte command.
func execute(cmd *exec.Cmd) error {
fmt.Println("+", strings.Join(cmd.Args, " "))
cmd.Env = os.Environ()
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
return cmd.Run()
}
// helper function returns true if directory dir is empty.
func isDirEmpty(dir string) bool {
f, err := os.Open(dir)
if err != nil {
return true
}
defer f.Close()
_, err = f.Readdir(1)
return err == io.EOF
}