fix: exists check, projectName validation on pre-enter

This commit is contained in:
2026-06-11 16:31:18 +02:00
parent 65f2efd879
commit a6a6d13e5c
2 changed files with 16 additions and 3 deletions
+6 -1
View File
@@ -29,7 +29,8 @@ async function main() {
return "Project name is required";
if (!/^[a-zA-Z0-9-]+$/.test(value))
return "Project name can only contain letters, numbers, and dashes";
if (fs.existsSync(value))
const targetDir = path.resolve(process.cwd(), value);
if (fs.existsSync(targetDir))
return "Directory already exists";
return true;
},
@@ -39,6 +40,10 @@ async function main() {
process.exit(1);
}
}
if (!/^[a-zA-Z0-9-]+$/.test(projectName)) {
console.error("❌ Project name can only contain letters, numbers, and dashes");
process.exit(1);
}
const templateType = await select({
message: "Please select a template type:",
choices: projectTypes,