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) {
|
if (args.dryRun) {
|
||||||
ora().info(dim(`--dry-run enabled, skipping.`));
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
||||||
} else if (gitResponse) {
|
} else if (gitResponse) {
|
||||||
await execaCommand('git init', { cwd });
|
// Add a check to see if there is already a .git directory and skip 'git init' if yes (with msg to output)
|
||||||
ora().succeed('Git repository created!');
|
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 {
|
} else {
|
||||||
await info(
|
await info(
|
||||||
'Sounds good!',
|
'Sounds good!',
|
||||||
|
|
Loading…
Reference in a new issue