deployHtmlToServer.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var path = require('path');
  2. var fs = require('fs');
  3. var sftp = require('./uploadSftp');
  4. var rimraf = require('rimraf');
  5. var nativePath = `dist/temp`;
  6. //创建临时目录
  7. fs.mkdirSync(nativePath);
  8. var indexHtml = fs.readFileSync('dist/index.html');
  9. fs.writeFileSync(nativePath + path.sep + 'index.html', indexHtml);
  10. var editHtml = fs.readFileSync('dist/editor.html');
  11. fs.writeFileSync(nativePath + path.sep + 'editor.html', editHtml);
  12. var shareHtml = fs.readFileSync('dist/share.html');
  13. fs.writeFileSync(nativePath + path.sep + 'share.html', shareHtml);
  14. // var shareHtml = fs.readFileSync('dist/login.html');
  15. // fs.writeFileSync(nativePath + path.sep + 'login.html', shareHtml);
  16. // var consoleHtml = fs.readFileSync('dist/console.html');
  17. // fs.writeFileSync(nativePath + path.sep + 'console.html', consoleHtml);
  18. var serverPath = `/var/www/html/projects/queenshow`;
  19. var ftpUtils = new sftp({
  20. remotePath: serverPath,
  21. path: nativePath,
  22. username: 'root',
  23. password: 'MmxInfish@2020',
  24. host: '124.71.139.24',
  25. verbose: true,
  26. });
  27. ftpUtils.apply(function () {
  28. //删除maps文件夹
  29. rimraf.sync(nativePath);
  30. console.log(`ftp upload success!`);
  31. });