mirror of
https://github.com/thegeeklab/wp-git-action.git
synced 2024-11-10 03:20:40 +00:00
44 lines
528 B
Go
44 lines
528 B
Go
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,
|
|
)
|
|
|
|
cmd := &types.Cmd{
|
|
Cmd: execabs.Command("rsync", args...),
|
|
}
|
|
cmd.Dir = src
|
|
|
|
return cmd
|
|
}
|