MCPcopy Create free account
hub / github.com/TanStack/cli / confirmTargetDirectorySafety

Function confirmTargetDirectorySafety

packages/cli/src/cli.ts:264–293  ·  view source on GitHub ↗
(
    targetDir: string,
    forced?: boolean,
  )

Source from the content-addressed store, hash-verified

262 const program = new Command()
263
264 async function confirmTargetDirectorySafety(
265 targetDir: string,
266 forced?: boolean,
267 ) {
268 if (forced) {
269 return
270 }
271
272 if (!fs.existsSync(targetDir)) {
273 return
274 }
275
276 if (!fs.statSync(targetDir).isDirectory()) {
277 throw new Error(`Target path exists and is not a directory: ${targetDir}`)
278 }
279
280 if (fs.readdirSync(targetDir).length === 0) {
281 return
282 }
283
284 const shouldContinue = await confirm({
285 message: `Target directory "${targetDir}" already exists and is not empty. Continue anyway?`,
286 initialValue: false,
287 })
288
289 if (isCancel(shouldContinue) || !shouldContinue) {
290 cancel('Operation cancelled.')
291 process.exit(0)
292 }
293 }
294
295 async function confirmCreateOptions(finalOptions: Options) {
296 const lines: Array<string> = []

Callers 2

startDevWatchModeFunction · 0.85
handleCreateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected