@@ -14,13 +14,13 @@ import (
14
14
)
15
15
16
16
const (
17
- // ConfFileName represent config file name
18
- ConfFileName = "commitlint.yaml"
17
+ // DefaultFile represent default config file name
18
+ DefaultFile = "commitlint.yaml"
19
19
)
20
20
21
21
// GetConfig returns parses config file, validate it and returns config instance
22
22
func GetConfig (confPath string ) (* lint.Config , error ) {
23
- confFilePath , useDefault , err := GetConfigPath (confPath )
23
+ confFilePath , useDefault , err := getConfigPath (confPath )
24
24
if err != nil {
25
25
return nil , err
26
26
}
@@ -41,19 +41,19 @@ func GetConfig(confPath string) (*lint.Config, error) {
41
41
return conf , nil
42
42
}
43
43
44
- // GetConfigPath returns config file path following below order
44
+ // getConfigPath returns config file path following below order
45
45
// 1. commitlint.yaml in current directory
46
46
// 2. confFilePath parameter
47
47
// 3. use default config
48
- func GetConfigPath (confFilePath string ) (string , bool , error ) {
48
+ func getConfigPath (confFilePath string ) (confPath string , isDefault bool , retErr error ) {
49
49
// get current directory
50
50
currentDir , err := os .Getwd ()
51
51
if err != nil {
52
52
return "" , false , err
53
53
}
54
54
55
55
// check if conf file exists in current directory
56
- currentDirConf := filepath .Join (currentDir , ConfFileName )
56
+ currentDirConf := filepath .Join (currentDir , DefaultFile )
57
57
if _ , err1 := os .Stat (currentDirConf ); ! os .IsNotExist (err1 ) {
58
58
return currentDirConf , false , nil
59
59
}
@@ -112,26 +112,6 @@ func Validate(conf *lint.Config) error {
112
112
return nil
113
113
}
114
114
115
- // DefaultConfToFile writes default config to given file
116
- func DefaultConfToFile (isOnlyEnabled bool ) error {
117
- outPath := filepath .Join ("." , filepath .Clean (ConfFileName ))
118
- if ! isOnlyEnabled {
119
- return WriteConfToFile (outPath , defConf )
120
- }
121
-
122
- confClone := & lint.Config {
123
- Formatter : defConf .Formatter ,
124
- Rules : map [string ]lint.RuleConfig {},
125
- }
126
-
127
- for ruleName , r := range defConf .Rules {
128
- if r .Enabled {
129
- confClone .Rules [ruleName ] = r
130
- }
131
- }
132
- return WriteConfToFile (outPath , confClone )
133
- }
134
-
135
115
// WriteConfToFile util func to write config object to given file
136
116
func WriteConfToFile (outFilePath string , conf * lint.Config ) (retErr error ) {
137
117
file , err := os .Create (outFilePath )
0 commit comments