Skip to content

Commit 539fbd7

Browse files
refactor(cmd): move print messages to action
1 parent 0aeb04a commit 539fbd7

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

cmd/callback.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ func Init(confPath string, isGlobal, isReplace bool) error {
1919
if err != nil {
2020
return err
2121
}
22-
23-
err = setGitConf(hookDir, isGlobal)
24-
if err != nil {
25-
return err
26-
}
27-
28-
fmt.Println("commitlint init successfully")
29-
return nil
22+
return setGitConf(hookDir, isGlobal)
3023
}
3124

3225
// Lint is the callback function for lint command

cmd/cmd.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ func initCmd() *cli.Command {
5959
isReplace := ctx.Bool("replace")
6060

6161
err := Init(confPath, isGlobal, isReplace)
62-
if isHookExists(err) {
63-
fmt.Println("commitlint init failed")
64-
fmt.Println("run with --replace to replace existing files")
65-
return nil
62+
if err != nil {
63+
if isHookExists(err) {
64+
fmt.Println("commitlint init failed")
65+
fmt.Println("run with --replace to replace existing files")
66+
return nil
67+
}
68+
return err
6669
}
67-
return err
70+
71+
fmt.Println("commitlint init successfully")
72+
return nil
6873
},
6974
}
7075
}

0 commit comments

Comments
 (0)