File tree Expand file tree Collapse file tree 3 files changed +9
-17
lines changed Expand file tree Collapse file tree 3 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,6 @@ const (
19
19
HookDir = ".commitlint/hooks"
20
20
)
21
21
22
- // VersionCallback is the version command callback
23
- var VersionCallback = func () error {
24
- fmt .Println ("commitlint" )
25
- return nil
26
- }
27
-
28
22
func initCallback (ctx * cli.Context ) (retErr error ) {
29
23
// get user home dir
30
24
homeDir , err := os .UserHomeDir ()
Original file line number Diff line number Diff line change 2
2
package cmd
3
3
4
4
import (
5
+ "fmt"
6
+
5
7
"github.com/urfave/cli/v2"
6
8
)
7
9
10
+ var verTmpl = `commitlint version %s - built from %s on %s
11
+ `
12
+
8
13
// New returns commitlint cli.App
9
- func New () * cli.App {
14
+ func New (versionNo , commitHash , builtTime string ) * cli.App {
10
15
createCmd := & cli.Command {
11
16
Name : "create" ,
12
17
Usage : "create commitlint config, hooks files" ,
@@ -69,7 +74,8 @@ func New() *cli.App {
69
74
Name : "version" ,
70
75
Usage : "prints commitlint version" ,
71
76
Action : func (c * cli.Context ) error {
72
- return VersionCallback ()
77
+ fmt .Printf (verTmpl , versionNo , commitHash , builtTime )
78
+ return nil
73
79
},
74
80
}
75
81
Original file line number Diff line number Diff line change 15
15
BuildTime = ""
16
16
)
17
17
18
- var verTmpl = `commitlint %s-%s %s
19
- `
20
-
21
18
func main () {
22
- cmd .VersionCallback = func () error {
23
- fmt .Printf (verTmpl , Version , Commit , BuildTime )
24
- return nil
25
- }
26
-
27
- app := cmd .New ()
19
+ app := cmd .New (Version , Commit , BuildTime )
28
20
err := app .Run (os .Args )
29
21
if err != nil {
30
22
fmt .Println ("Error: " , err )
You can’t perform that action at this time.
0 commit comments