teambition / gulp-ssh

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

Best way to close connection? #36

Closed suederade closed 8 years ago

suederade commented 8 years ago

I need to run some shell commands, but if I run close after the shell command, the close runs before the shell commands run. Is there a way to best practice for closing the connection when you are done or when the shell commands are finished?

On the examples there is a .pipe(gulp.dest()) but that is not closing the connection.

ssh.shell(['cd ~/bom-test', 'rm -rf node_modules/', 'npm install --production', 'exit']);

the npm command doesn't finish if the connection is closed prematurely.

zensh commented 8 years ago
ssh.shell(['cd ~/bom-test', 'rm -rf node_modules/', 'npm install --production'])
  .pipe(gulp.dest())

will auto close the connection. Or you can try:

ssh.shell(['cd ~/bom-test', 'rm -rf node_modules/', 'npm install --production'])
  .on('end', function() { ssh.close() })
  .pipe(gulp.dest())
suederade commented 8 years ago

Ok thanks, I'll try that. For some reason the first one was not automatically closing the session and was just hanging.