Skip to content

Commit a81a020

Browse files
feat(cmd): add file flag to config/create command
1 parent f1c060b commit a81a020

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

internal/cmd/callback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func hookCreate(confPath string, isReplace bool) error {
4747
}
4848

4949
// configCreate is the callback function for create config command
50-
func configCreate(isReplace bool) error {
50+
func configCreate(fileName string, isReplace bool) error {
5151
defConf := config.Default()
52-
outPath := filepath.Join(".", config.ConfigFile)
52+
outPath := filepath.Join(".", fileName)
5353
// if config file already exists skip creating or overwriting it
5454
if _, err := os.Stat(outPath); !os.IsNotExist(err) {
5555
if !isReplace {

internal/cmd/cmd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ func configCmd() *cli.Command {
105105
Usage: "Replace conf file if already exists",
106106
Value: false,
107107
},
108+
&cli.StringFlag{
109+
Name: "file",
110+
Usage: "Config file name",
111+
Value: ".commitlint.yaml",
112+
},
108113
},
109114
Action: func(ctx *cli.Context) error {
110115
isReplace := ctx.Bool("replace")
111-
err := configCreate(isReplace)
116+
fileName := ctx.String("file")
117+
err := configCreate(fileName, isReplace)
112118
if err != nil {
113119
if isConfExists(err) {
114120
fmt.Println("config create failed")

0 commit comments

Comments
 (0)