const fs = require('fs'); const base = 'D:/SoftProject/yunhai/UserBase/front/src/api/'; const files = ['apiDefinitions.ts', 'globals.d.ts']; // 仅匹配单引号包裹的 api-path key:'xxxController.method' const re = /'([a-zA-Z]+?)Controller\./g; for (const f of files) { const p = base + f; let s = fs.readFileSync(p, 'utf8'); const before = (s.match(re) || []).length; s = s.replace(re, (m, ns) => "'" + ns.charAt(0).toUpperCase() + ns.slice(1) + "."); fs.writeFileSync(p, s, 'utf8'); const after = (s.match(re) || []).length; console.log(f + ': replaced ' + before + ' -> remaining ' + after); }