jerrysu / gulp-rsync

Gulp plugin for deploying files via rsync
119 stars 51 forks source link

Clean not cleaning #29

Open rctneil opened 8 years ago

rctneil commented 8 years ago

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

stephenchai commented 8 years ago

I'm having this same issue as well. I am using clean: true in combinations with recursive: true.

Any insights would be appreciated, thanks!

leopoldw commented 8 years ago

Also having the same issue.

sebenik commented 8 years ago

+1

trafiq commented 8 years ago

I'm also experiencing this. Did anyone manage to get it working?

mikehuebner commented 8 years ago

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.

COLABORATI commented 8 years ago

please use the command option to check the generated rsync command.

nlenkowski commented 8 years ago

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.

TCB13 commented 7 years ago

@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.

robinzimmermann commented 7 years ago

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.

markstos commented 5 years ago

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.

JacobDB commented 5 years ago

For anyone else coming to this, here's what worked for me:

  1. Change rsync task from gulp.src("./dev/**/*") to gulp.src("./dev/")
  2. Set recursive to true
  3. Set clean to true

It's working perfectly now 🙂