MCPcopy Create free account
hub / github.com/netlify/cli / carefullyWriteFile

Function carefullyWriteFile

src/commands/database/db-init.ts:55–73  ·  view source on GitHub ↗
(filePath: string, data: string, projectRoot: string)

Source from the content-addressed store, hash-verified

53}
54
55const carefullyWriteFile = async (filePath: string, data: string, projectRoot: string) => {
56 if (existsSync(filePath)) {
57 type Answers = {
58 overwrite: boolean
59 }
60 const answers = await inquirer.prompt<Answers>([
61 {
62 type: 'confirm',
63 name: 'overwrite',
64 message: `Overwrite existing file .${filePath.replace(projectRoot, '')}?`,
65 },
66 ])
67 if (answers.overwrite) {
68 await writeFile(filePath, data)
69 }
70 } else {
71 await writeFile(filePath, data)
72 }
73}
74
75const readDirectoryEntries = async (dir: string): Promise<string[]> => {
76 try {

Callers 2

installDependenciesFunction · 0.85
scaffoldStarterFunction · 0.85

Calls 1

writeFileFunction · 0.50

Tested by

no test coverage detected