2024-05-05 20:14:55 +00:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/thegeeklab/wp-plugin-go/v2/types"
|
|
|
|
|
|
|
|
"golang.org/x/sys/execabs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SyncDirectories(exclude []string, del bool, src, dest string) *types.Cmd {
|
|
|
|
args := []string{
|
|
|
|
"-r",
|
|
|
|
"--exclude",
|
|
|
|
".git",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, item := range exclude {
|
|
|
|
args = append(
|
|
|
|
args,
|
|
|
|
"--exclude",
|
|
|
|
item,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if del {
|
|
|
|
args = append(
|
|
|
|
args,
|
|
|
|
"--delete",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
args = append(
|
|
|
|
args,
|
|
|
|
".",
|
|
|
|
dest,
|
|
|
|
)
|
|
|
|
|
2024-05-06 20:43:56 +00:00
|
|
|
cmd := &types.Cmd{
|
|
|
|
Cmd: execabs.Command("rsync", args...),
|
|
|
|
}
|
2024-05-05 20:14:55 +00:00
|
|
|
cmd.Dir = src
|
|
|
|
|
2024-05-06 20:43:56 +00:00
|
|
|
return cmd
|
2024-05-05 20:14:55 +00:00
|
|
|
}
|