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:
parent
a88363ce79
commit
5c64324c0a
2 changed files with 15 additions and 2 deletions
5
.changeset/try-button-rumor.md
Normal file
5
.changeset/try-button-rumor.md
Normal 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.
|
|
@ -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!',
|
||||
|
|
Loading…
Reference in a new issue