jerrysu / gulp-rsync

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

Unexpected filenames/root option redundant? #6

Open matthewwithanm opened 9 years ago

matthewwithanm commented 9 years ago

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!

jerrysu commented 9 years ago

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

matthewwithanm commented 9 years ago

Woot! :confetti_ball:

brenwell commented 9 years ago

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

SleepWalker commented 9 years ago

@brenwell try to use root: 'dist' option