publish.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * iFHS7.
  5. * ;BBMBMBMc rZMBMBR BMB
  6. * MBEr:;PBM, 7MBMMEOBB: BBB RBW
  7. * XK: BO SB. :SZ MBM. c;; ir BBM :FFr :SSF: ;xBMB:r iuGXv. i:. iF2;
  8. * DBBM0r. :D S7 ;XMBMB GMBMu. MBM: BMB MBMBBBMBMS WMBMBMBBK MBMBMBM BMBRBMBW .MBMBMBMBB
  9. * :JMRMMD .. , 1MMRM1; ;MBMBBR: MBM ;MB: BMB: MBM. RMBr sBMH BM0 UMB, BMB. KMBv
  10. * ;. XOW B1; :uM: 1RE, i .2BMBs rMB. MBO MBO JMB; MBB MBM BBS 7MBMBOBM: MBW :BMc
  11. * OBRJ.SEE MRDOWOR, 3DE:7OBM . ;BMB RMR7BM BMB MBB. BMB ,BMR .BBZ MMB rMB, BMM rMB7
  12. * :FBRO0D0 RKXSXPR. JOKOOMPi BMBSSWBMB; BMBB: MBMB0ZMBMS .BMBOXRBMB MBMDE RBM2;SMBM; MBB xBM2
  13. * iZGE O0SHSPO. uGZ7. sBMBMBDL :BMO OZu:BMBK, rRBMB0; ,EBMB xBMBr:ER. RDU :OO;
  14. * ,BZ, 1D0 RPSFHXR. xWZ .SMr . .BBB
  15. * :0BMRDG RESSSKR. 2WOMBW; BMBMR
  16. * i0BM: SWKHKGO MBDv
  17. * .UB OOGDM. MK, Copyright (c) 2015-2019. 斯伯坦机器人
  18. * , XMW ..
  19. * r All rights reserved.
  20. *
  21. * ********************************************************************************************************************
  22. */
  23. const Client = require("node-ssh");
  24. const ssh = new Client();
  25. ssh.connect({
  26. host: process.env.npm_package_remote_host,
  27. port: "22",
  28. username: process.env.npm_package_remote_user,
  29. password: process.env.npm_package_remote_password
  30. }).then(() => {
  31. const failedList = [];
  32. ssh.putDirectory(
  33. process.env.npm_package_remote_local,
  34. process.env.npm_package_remote_path,
  35. {
  36. recursive: true,
  37. concurrency: 1,
  38. tick: function(localPath, remotePath, error) {
  39. if (error) {
  40. failedList.push(localPath);
  41. }
  42. }
  43. }
  44. ).then(status => {
  45. if (failedList.length > 0) {
  46. console.log("发布失败");
  47. console.log("failed transfers", failedList.join(", "));
  48. } else {
  49. console.log(status ? "发布成功" : "发布失败");
  50. }
  51. ssh.dispose();
  52. });
  53. });