0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-22 00:00:39 +00:00
wp-git-action/plugin/rsync.go

51 lines
624 B
Go

package plugin
import (
"os"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
)
func SyncDirectories(exclude []string, del bool, src, dest string, debug bool) *plugin_exec.Cmd {
args := []string{
"-r",
"--exclude",
".git",
}
for _, item := range exclude {
args = append(
args,
"--exclude",
item,
)
}
if del {
args = append(
args,
"--delete",
)
}
if debug {
args = append(
args,
"--stats",
)
}
args = append(
args,
".",
dest,
)
cmd := plugin_exec.Command("rsync", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = src
return cmd
}