From ab4285596464bb38f7c76ef6e42b733f70ce4004 Mon Sep 17 00:00:00 2001 From: saseungmin Date: Sun, 22 Jun 2025 23:07:32 +0900 Subject: [PATCH] fix: allow project creation in directories with only .git folder - Enable creating projects in freshly cloned empty repositories - Resolves issue where users couldn't create projects in cloned repos --- .../create-react-native-library/src/input.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/create-react-native-library/src/input.ts b/packages/create-react-native-library/src/input.ts index 387438548..905407d51 100644 --- a/packages/create-react-native-library/src/input.ts +++ b/packages/create-react-native-library/src/input.ts @@ -210,8 +210,23 @@ export async function createQuestions({ return 'Cannot be empty'; } - if (fs.pathExistsSync(path.join(process.cwd(), input))) { - return 'Directory already exists'; + const targetPath = path.join(process.cwd(), input); + + if (fs.pathExistsSync(targetPath)) { + const stat = fs.statSync(targetPath); + + if (!stat.isDirectory()) { + return 'Path exists and is not a directory'; + } + + const files = fs.readdirSync(targetPath); + + const isEmpty = + files.length === 0 || (files.length === 1 && files[0] === '.git'); + + if (!isEmpty) { + return 'Directory already exists'; + } } return true;