mirror of
https://ghproxy.net/https://github.com/jonbp/wp-cli-sync.git
synced 2025-10-04 02:35:05 +08:00
Adding rsync exclude support
This commit is contained in:
parent
8877d68d43
commit
e10354130d
2 changed files with 15 additions and 1 deletions
|
@ -34,6 +34,11 @@ DEV_ACTIVATED_PLUGINS=""
|
|||
|
||||
# Plugins deactivated on sync
|
||||
DEV_DEACTIVATED_PLUGINS=""
|
||||
|
||||
# Dirs to exclude from sync
|
||||
# Multiple dirs can be provided by separating with a comma
|
||||
# Use dir names or paths relative to uploads dir
|
||||
DEV_SYNC_DIR_EXCLUDES=""
|
||||
```
|
||||
|
||||
3. Run `wp sync` from the project root.
|
||||
|
|
|
@ -73,9 +73,18 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|||
* TASK: Sync Uploads Folder
|
||||
*/
|
||||
$task_name = 'Sync Uploads Folder';
|
||||
|
||||
$excludes = '';
|
||||
if ($exclude_dirs = env('DEV_SYNC_DIR_EXCLUDES')) {
|
||||
$exclude_dirs = explode(',', $exclude_dirs);
|
||||
foreach ($exclude_dirs as $dir) {
|
||||
$excludes .= ' --exclude=' . $dir;
|
||||
}
|
||||
}
|
||||
|
||||
if (`which rsync`) {
|
||||
task_message($task_name);
|
||||
$command = 'rsync -avhP '.$ssh_username.'@'.$ssh_hostname.':'.$rem_proj_loc.'/web/app/uploads/ ./web/app/uploads/';
|
||||
$command = 'rsync -avhP '.$ssh_username.'@'.$ssh_hostname.':'.$rem_proj_loc.'/web/app/uploads/ ./web/app/uploads/' . $excludes;
|
||||
system($command);
|
||||
} else {
|
||||
task_message($task_name.' task not ran, please install \'rsync\'', 'Error', 31);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue