0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-10-31 19:50:38 +00:00
wp-git-action/plugin/rsync.go

51 lines
624 B
Go
Raw Normal View History

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
2024-05-06 20:43:56 +00:00
return cmd
}