gulp-rsync icon indicating copy to clipboard operation
gulp-rsync copied to clipboard

Unexpected filenames/root option redundant?

Open matthewwithanm opened this issue 11 years ago • 4 comments

Thanks for the plugin! It works great, but I have a small question about a part of the API that doesn't seem to gel with how gulp wants you to do things.

Initially I tried the following:

gulp.src('./path/to/assets/**')
  .pipe(rsync({
    hostname: 'host',
    destination: '/the/place/to/be'
  }));

My expectation was that, given a file ./path/to/assets/image.jpg, the file created on the remote would be /the/place/to/be/image.jpg. This would be consistent with gulp.dest and how the base option works:

options.base

Type: String Default: everything before a glob starts (see [glob2base])

E.g., consider somefile.js in client/js/somedir:

gulp.src('client/js/**/*.js') // Matches 'client/js/somedir/somefile.js' and resolves `base` to `client/js/`
  .pipe(minify())
  .pipe(gulp.dest('build'));  // Writes 'build/somedir/somefile.js'

gulp.src('client/js/**/*.js', { base: 'client' })
  .pipe(minify())
  .pipe(gulp.dest('build'));  // Writes 'build/js/somedir/somefile.js'

Instead, I was surprised to find that the result file was /the/place/to/be/path/to/assets/image.jpg—as though I had set base to . in my gulp.src call. After some digging, I saw that gulp-rsync has a root option to accomplish what I wanted.

So it seems to me that gulp-rsync is essentially ignoring the base which, if it behaved as gulp expected, would make the root option redundant. It would be cool if the behavior were updated to behave more like gulp.dest and similar plugins.

Apologies in advance if I'm missing something!

matthewwithanm avatar Oct 17 '14 19:10 matthewwithanm

@matthewwithanm: Thanks for referring me to the base option in gulp.src. I was not aware of it! I'll look into using it and properly deprecating the root option if it can be used.

jerrysu avatar Oct 17 '14 19:10 jerrysu

Woot! :confetti_ball:

matthewwithanm avatar Oct 17 '14 21:10 matthewwithanm

Hey everyone, I would also like to thank you for the lib.

I am having a similar issue I think. I am trying to rsync the contents of a folder to a remote folder of a different name

  gulp.src('dist/**').pipe rsync
    username: 'me'
    hostname: 'example.com'
    destination: 'www/public/'

and the result is

~/www/public/dist/index.html

how can I make it produce the following

~/www/public/index.html

Thanks

brenwell avatar Feb 16 '15 14:02 brenwell

@brenwell try to use root: 'dist' option

SleepWalker avatar Feb 18 '15 11:02 SleepWalker