Guest User

Untitled

a guest
Oct 30th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. async function CheckIfDirectoryIsNotEmpty() {
  2.  
  3. let value;
  4. let Client = require('ssh2-sftp-client');
  5. let sftp = new Client();
  6.  
  7. sftp.connect({
  8. host: 'xxxxx',
  9. port: 'xx',
  10. username: 'xxxxxxxx',
  11. password: 'xxxxxxxx'
  12.  
  13. }).then(() => {
  14. return sftp.list('/opt/cm-shared-data/example/')
  15. }).then((data) => {
  16. if(data.length == 0){
  17. value = 0;
  18. }
  19. else { value = 1;}
  20. sftp.end();
  21. return value;
  22. });
  23. }
  24.  
  25. async function start() {
  26.  
  27.  
  28. var a = CheckIfDirectoryIsNotEmpty();
  29.  
  30. console.log(a); // "undefined"
Add Comment
Please, Sign In to add comment