diff options
author | 2023-01-26 21:34:49 +0100 | |
---|---|---|
committer | 2023-01-26 15:34:49 -0500 | |
commit | 5c64324c0a1b06e836c3d53668940faca4cb517d (patch) | |
tree | 486445058b2413f3ccff9bd866ec772c85801bfb /packages/create-astro/src | |
parent | a88363ce798e8cd83db2ada47253017dd7f7678e (diff) | |
download | astro-5c64324c0a1b06e836c3d53668940faca4cb517d.tar.gz astro-5c64324c0a1b06e836c3d53668940faca4cb517d.tar.zst astro-5c64324c0a1b06e836c3d53668940faca4cb517d.zip |
Add a check for existing .git directory (and skip if one is found). (#5953)
* Add a check for existing .git directory (and skip if one is found).
* Changeset attempt :-)
* Update .changeset/try-button-rumor.md
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
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!', |