// import routes from '../src/routes/route.h5'; // console.log(routes); // const fs = require("fs"); import * as fs from 'fs'; let ooo = fs.readFileSync('./src/routes/route.h5.ts', "utf-8"); let flag = false; let _arr: string[] = []; ooo.split("\n").forEach(element => { if (element.indexOf("/// 结束 请勿修改 ------") > -1) { flag = false; } if (flag) { let i = new RegExp('(?<="/).+(?=")').exec(element.trim())?.[0]; if (i) { _arr.push(i); } } if (element.indexOf("/// 开始 请勿修改 ------") > -1) { flag = true; } }); let configName = fs.readFileSync("./src/app.config.ts", "utf-8"); let list = configName.split("\n"); list[0] = `let pages = ${JSON.stringify(_arr)};`; console.log(list); fs.writeFileSync("./src/app.config.ts", list.join('\n'), "utf-8"); // ooo.match(regex) // console.log(ooo.match(new RegExp("(?=开始)"))) // console.log(new RegExp("^(?=开始)").exec(ooo))