main.js 766 B

123456789101112131415161718192021222324252627282930313233
  1. const util = require('util');
  2. const child_process = require('child_process');
  3. const exec = util.promisify(child_process.exec);
  4. const fs = require('fs-extra')
  5. const PATH = `./.laser-lib-path`
  6. const inInit = fs.existsSync(PATH)
  7. const initLocal = inInit && fs.readFileSync(PATH).toString()
  8. const buildPaths = [
  9. `build`,
  10. ...inInit ? [initLocal] : []
  11. ]
  12. const runBuild = async () => {
  13. console.log('正在进行打包')
  14. await exec(`yarn build-c`);
  15. console.log('打包已完成正在发布到git仓库')
  16. if (initLocal) {
  17. try {
  18. await exec(`
  19. cd ${initLocal}
  20. git pull
  21. git add -A
  22. git commit -m 'fix: 更新sdk'
  23. git push
  24. `)
  25. console.log('发布成功')
  26. } catch {
  27. console.error('自动发布失败,请手动上传')
  28. }
  29. }
  30. }
  31. runBuild()