forked from eficode-academy/git-katas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further improve error handling in setup.ps1
Resolves: eficode-academy#243
- Loading branch information
1 parent
33249c1
commit 5636667
Showing
1 changed file
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
# First cleanup if there is an old exercise repository | ||
if (Test-Path .\exercise) { | ||
Remove-Item .\exercise\ -Force -Recurse -ErrorAction:Stop | ||
} | ||
try { | ||
if (Test-Path .\exercise) { | ||
Remove-Item .\exercise\ -Force -Recurse -ErrorAction:Stop | ||
} | ||
|
||
# Initialize a new repository | ||
git init exercise | ||
|
||
# Initialize a new repository | ||
git init exercise | ||
# Go there | ||
Set-Location .\exercise\ | ||
|
||
# Go there | ||
Set-Location .\exercise\ | ||
# Using this as a check if the exercise folder was created successfully | ||
# If there was an issue during git init the Get-ChildItem will fail | ||
$null = Get-ChildItem . -ErrorAction:Stop | ||
|
||
# Set local git user name and email to distinguish commits. | ||
git config --local user.name "git-katas trainer bot" | ||
git config --local user.email "git-katas@example.com" | ||
# Set local git user name and email to distinguish commits. | ||
git config --local user.name "git-katas trainer bot" | ||
git config --local user.email "git-katas@example.com" | ||
} | ||
catch { | ||
Write-Error "Error during exercise creation`nPlease try removing the exercise folder manually and run setup.ps1 again." | ||
} | ||
|