deployHtmlToServer.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 h5Html = fs.readFileSync('dist/h5.html');
  11. fs.writeFileSync(nativePath + path.sep + 'h5.html', h5Html);
  12. // var shareHtml = fs.readFileSync('dist/login.html');
  13. // fs.writeFileSync(nativePath + path.sep + 'login.html', shareHtml);
  14. // var consoleHtml = fs.readFileSync('dist/console.html');
  15. // fs.writeFileSync(nativePath + path.sep + 'console.html', consoleHtml);
  16. var serverPath = `/var/www/queenshow/stat`;
  17. var ftpUtils = new sftp({
  18. remotePath: serverPath,
  19. path: nativePath,
  20. username: 'root',
  21. password: 'MmxInfish@2020',
  22. host: '124.71.139.24',
  23. verbose: true,
  24. });
  25. ftpUtils.apply(function () {
  26. //删除maps文件夹
  27. rimraf.sync(nativePath);
  28. console.log(`ftp upload success!`);
  29. });