diff options
Diffstat (limited to 'packages/create-astro/src')
-rw-r--r-- | packages/create-astro/src/index.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index f1571398f..71c8a2ad5 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -298,8 +298,16 @@ export async function main() { if (args.dryRun) { ora().info(dim(`--dry-run enabled, skipping.`)); } else if (gitResponse) { - await execaCommand('git init', { cwd }); - ora().succeed('Git repository created!'); + // Add a check to see if there is already a .git directory and skip 'git init' if yes (with msg to output) + const gitDir = './.git'; + if (fs.existsSync(gitDir)) { + ora().info( + dim('A .git directory already exists. Skipping creating a new Git repository.') + ); + } else { + await execaCommand('git init', { cwd }); + ora().succeed('Git repository created!'); + } } else { await info( 'Sounds good!', |