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

Function write

packages/create-vite/src/index.ts:673–688  ·  view source on GitHub ↗
(file: string, content?: string)

Source from the content-addressed store, hash-verified

671 )
672
673 const write = (file: string, content?: string) => {
674 const targetPath = path.join(root, renameFiles[file] ?? file)
675 if (content) {
676 fs.writeFileSync(targetPath, content)
677 } else if (file === 'index.html') {
678 const templatePath = path.join(templateDir, file)
679 const templateContent = fs.readFileSync(templatePath, 'utf-8')
680 const updatedContent = templateContent.replace(
681 /<title>.*?<\/title>/,
682 `<title>${packageName}</title>`,
683 )
684 fs.writeFileSync(targetPath, updatedContent)
685 } else {
686 copy(path.join(templateDir, file), targetPath)
687 }
688 }
689
690 const files = fs.readdirSync(templateDir)
691 for (const file of files.filter((f) => f !== 'package.json')) {

Callers 1

initFunction · 0.85

Calls 1

copyFunction · 0.85

Tested by

no test coverage detected