Clean not cleaning
rctneil opened this issue ยท 11 comments
Hey,
I have set gulp-rsync to to sync a selection of files over to a server with the clean option enabled. If I delete a file then then run my gulp command to do the sync, the file is not deleted on the server.
I have tried using a glob to select the files like so: .src(config.paths.srcAssets + '**/*')
as well as just the directory like this: .src(config.paths.srcAssets)
but it seems to make no difference.
Is there a way to ensure that a local file deletion is replicated in the sync?
Thanks,
Neil
I'm having this same issue as well. I am using clean: true
in combinations with recursive: true
.
Any insights would be appreciated, thanks!
Also having the same issue.
+1
I'm also experiencing this. Did anyone manage to get it working?
Same issue.
Dug into the code a bit and the command is running properly, but the delete is not happening. I believe its just the process of which the commands are being used? I'm not sure on any of it, trying to modify it to work but I can't seem to get it to.
please use the command
option to check the generated rsync command.
At first I had the same issue, but I was able to get the clean option working with the following configuration:
gulp.task('deploy', function() {
var rsyncConf = {
hostname: 'hostname',
username: 'username',
destination: '/var/www/htdocs/',
exclude: ['node_modules', '.git', '.editorconfig', '.eslintrc.json', '.gitignore'],
clean: true,
compress: true,
emptyDirectories: true,
incremental: true,
recursive: true,
relative: true
};
return gulp.src('./')
.pipe(rsync(rsyncConf));
});
Note that when passing './*'
or './**'
to gulp.src() the clean option was ignored. When I began passing './'
the locally deleted files were deleted from the remote server correctly.
@nlenkowski I'm not sure how you can pass './'
to gulp.src()
when I do that no files are found by gulp, so nothing is passed to rsync. Can you explain this?
EDIT: Nevermind, I just noticed you're using the recursive: true
option and I was sourcing the files as a glob without the recursive: true
option. You solution works! I also added exclude: [".*", ".*/"]
to avoid uploading all kinds of dot files and folders.
Thanks, @nlenkowski. Using your post I got it to work by adding the recursive: true
option. According to the doc this shouldn't be necessary because I have archive: true
. But adding the recursive: true
option seems to workaround that.
I had the same result as @robinzimmermann I was already using archive: true
, but found when I deleted a directory on the source, it wasn't deleted on the destination. Once I added recursive: true
, that issue was fixed.
For anyone else coming to this, here's what worked for me:
- Change rsync task from
gulp.src("./dev/**/*")
togulp.src("./dev/")
- Set
recursive
totrue
- Set
clean
totrue
It's working perfectly now ๐