Skip to content

Commit

Permalink
Further improve error handling in setup.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
bothzoli authored and RandomSort committed Jul 1, 2020
1 parent 33249c1 commit 5636667
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions utils/make-exercise-repo.ps1
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."
}

0 comments on commit 5636667

Please sign in to comment.