start.ts 979 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // import routes from '../src/routes/route.h5';
  2. // console.log(routes);
  3. // const fs = require("fs");
  4. import * as fs from 'fs';
  5. let ooo = fs.readFileSync('./src/routes/route.h5.ts', "utf-8");
  6. let flag = false;
  7. let _arr: string[] = [];
  8. ooo.split("\n").forEach(element => {
  9. if (element.indexOf("/// 结束 请勿修改 ------") > -1) {
  10. flag = false;
  11. }
  12. if (flag) {
  13. let i = new RegExp('(?<="/).+(?=")').exec(element.trim())?.[0];
  14. if (i) {
  15. _arr.push(i);
  16. }
  17. }
  18. if (element.indexOf("/// 开始 请勿修改 ------") > -1) {
  19. flag = true;
  20. }
  21. });
  22. let configName = fs.readFileSync("./src/app.config.ts", "utf-8");
  23. let list = configName.split("\n");
  24. list[0] = `let pages = ${JSON.stringify(_arr)};`;
  25. console.log(list);
  26. fs.writeFileSync("./src/app.config.ts", list.join('\n'), "utf-8");
  27. // ooo.match(regex)
  28. // console.log(ooo.match(new RegExp("(?=开始)")))
  29. // console.log(new RegExp("^(?=开始)").exec(ooo))