mirror of
https://github.com/thegeeklab/wp-git-action.git
synced 2024-11-12 16:20:40 +00:00
34 lines
516 B
Go
34 lines
516 B
Go
package plugin
|
|
|
|
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
|
|
}
|