(root: string, newBody: string)
| 1024 | } |
| 1025 | |
| 1026 | function updateReactCompilerReadme(root: string, newBody: string) { |
| 1027 | editFile(path.resolve(root, `README.md`), (content) => { |
| 1028 | const h2Start = content.indexOf('## React Compiler') |
| 1029 | const bodyStart = content.indexOf('\n\n', h2Start) |
| 1030 | const compilerSectionEnd = content.indexOf('\n## ', bodyStart) |
| 1031 | if (h2Start === -1 || bodyStart === -1 || compilerSectionEnd === -1) { |
| 1032 | console.warn('Could not update compiler section in README.md') |
| 1033 | return content |
| 1034 | } |
| 1035 | return content.replace( |
| 1036 | content.slice(bodyStart + 2, compilerSectionEnd - 1), |
| 1037 | newBody, |
| 1038 | ) |
| 1039 | }) |
| 1040 | } |
| 1041 | |
| 1042 | function editFile(file: string, callback: (content: string) => string) { |
| 1043 | const content = fs.readFileSync(file, 'utf-8') |
no test coverage detected