(name: string, type: 'camel' | 'Camel' | 'UPPER_SNAKE')
| 14 | } |
| 15 | |
| 16 | const transformName = (name: string, type: 'camel' | 'Camel' | 'UPPER_SNAKE'): string => { |
| 17 | return name.split('-').map((s, i) => { |
| 18 | if (type === 'UPPER_SNAKE') { |
| 19 | if (i === 0) return s.toLocaleUpperCase() |
| 20 | return `_${s.toLocaleUpperCase()}` |
| 21 | } |
| 22 | |
| 23 | if (type === 'camel' && i === 0) return s |
| 24 | return s[0].toLocaleUpperCase() + s.substring(1) |
| 25 | }).join('') |
| 26 | } |
| 27 | |
| 28 | const modifyFile = (filePath: string, replaces: Array<string[]>) => { |
| 29 | // 1. 读取文件内容 |