Skip to content

Commit 2f3b9c4

Browse files
fix(cmd): check first for dir exists before create hook
1 parent 7ea5e43 commit 2f3b9c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/hook.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ func createHooks(confPath string, isReplace bool) error {
3434
}
3535

3636
func writeHooks(hookDir, confPath string, isReplace bool) error {
37-
err := os.MkdirAll(hookDir, os.ModePerm)
38-
if err != nil {
39-
return err
40-
}
41-
4237
// if commit-msg already exists skip creating or overwriting it
4338
if _, err := os.Stat(hookDir); !os.IsNotExist(err) {
4439
if !isReplace {
4540
return errHooksExist
4641
}
4742
}
4843

44+
err := os.MkdirAll(hookDir, os.ModePerm)
45+
if err != nil {
46+
return err
47+
}
48+
4949
// create hook file
5050
return hook.WriteHooks(hookDir, confPath)
5151
}

0 commit comments

Comments
 (0)