MCPcopy
hub / github.com/vitejs/vite / updateReactCompilerReadme

Function updateReactCompilerReadme

packages/create-vite/src/index.ts:1026–1040  ·  view source on GitHub ↗
(root: string, newBody: string)

Source from the content-addressed store, hash-verified

1024}
1025
1026function 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
1042function editFile(file: string, callback: (content: string) => string) {
1043 const content = fs.readFileSync(file, 'utf-8')

Callers 1

setupReactCompilerFunction · 0.85

Calls 3

editFileFunction · 0.70
resolveMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected