sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 25 forks source link

Documentation should include examples with error handling. #18

Closed onsightit closed 5 years ago

onsightit commented 5 years ago

The Documentation shows basic examples, but they should include examples with error handling. Not sure if I should use sftp.on('error', ...

Also, do you still need to call ssh.end()? I do not see it in the examples. Thanks!

sanketbajoria commented 5 years ago

@onsightit

I will update the documentation for this. Since, every method of ssh object return a Promise object. So, you can directly do the error handling in below manner.

var sftp = ssh.sftp() sftp.readdir("/").then((data) => { console.log(data); //file listing }).catch((err) => { console.log(err) })

No we don't need to call ssh.end(). As per the current documentation , use instead ssh.close() close() - (Promise) - Close the sshconnection and associated tunnels.

sanketbajoria commented 5 years ago

@onsightit Updated the documentation