teambition / gulp-ssh

SSH and SFTP tasks for gulp
184 stars 38 forks source link

gulpSSH.shell with gulp-watch #54

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi buddy, Thanks for your awesome plugin out here

I've a case where I want to copy .class files changes and then restarting tomcat6 every time there's a change

var watch = require('gulp-watch');

gulp.task('server', function () { watch('target/classes/com/MAIN/*/.class') .pipe(gulpSSH.dest('/var/lib/tomcat6/webapps/SOMEAPP/WEB-INF/classes/com/MAIN/')) .pipe(gulpSSH.shell(['service tomcat6 restart'], {autoExit: false})); });

I see that for every change the gulpSSH.dest is working just fine, but the gulpSSH.shell is working only once and not injected for the next times even when changes happens!

Can you help me with that please?

Thanks, Kind Regards

zensh commented 8 years ago

@Attrash-Islam gulpSSH.shell is not a writable stream. It is a readable stream. You should use it like this:

var stream = watch('target/classes/com/MAIN/*/.class')
stream.pipe(gulpSSH.dest('...'))
stream.on('data', function () {
  setTime(function () {
    gulpSSH.shell(['service tomcat6 restart'], {autoExit: false})
  }, 2000)
})
ghost commented 8 years ago

Thanks for your replay. :) I didn't try it yet, but I will