0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

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>
This commit is contained in:
Chris Banford 2023-01-26 21:34:49 +01:00 committed by GitHub
parent a88363ce79
commit 5c64324c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"create-astro": patch
---
Check for a pre-existing .git directory and if found, skip trying to create a new one.

View file

@ -298,8 +298,16 @@ export async function main() {
if (args.dryRun) {
ora().info(dim(`--dry-run enabled, skipping.`));
} else if (gitResponse) {
// 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!',