(
targetDir: string,
forced?: boolean,
)
| 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> = [] |
no outgoing calls
no test coverage detected