Skip to content

Commit

Permalink
Handle os.Mkdir error
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTsepelev committed Apr 26, 2021
1 parent c5dcd9c commit ec415bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ func DeleteGitHooks(fs afero.Fs) {
hooksPath := filepath.Join(getRootPath(), ".git", "hooks")

hooks, err := afero.ReadDir(fs, hooksPath)
log.Println("hooksPath", hooksPath)
if (err != nil) {
log.Println(".git/hooks directory does not exist, creating")
os.Mkdir(hooksPath, os.ModePerm)
log.Println("⚠️ ", au.Bold(".git/hooks"), "directory does not exist, creating")

if err := os.MkdirAll(hooksPath, os.ModePerm); err != nil {
log.Println(au.Brown("🚨 Failed to create"), au.Bold(".git/hooks"), au.Brown("directory"))
log.Fatal(err)
}
}

for _, file := range hooks {
Expand Down

0 comments on commit ec415bc

Please sign in to comment.