Skip to content

Commit 7181db0

Browse files
author
{cocoide}
committedSep 10, 2023
Merge branch 'develop'
2 parents 34532f4 + 649cb18 commit 7181db0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
 

‎internal/entity/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (c *Config) Config2PbVars() (pb.CodeFormatType, pb.LanguageType) {
6262
func ReadConfig() (Config, error) {
6363
var result Config
6464

65-
viper.AddConfigPath(".")
65+
viper.AddConfigPath("$HOME/.commitify")
6666
viper.SetConfigName("config")
6767
viper.SetConfigType("yaml")
6868
if err := viper.ReadInConfig(); err != nil {
@@ -75,7 +75,7 @@ func ReadConfig() (Config, error) {
7575
}
7676

7777
func WriteConfig(config Config) error {
78-
viper.AddConfigPath(".")
78+
viper.AddConfigPath("$HOME/.commitify")
7979
viper.SetConfigName("config")
8080
viper.SetConfigType("yaml")
8181
configMap := make(map[string]interface{})

‎main.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import (
99

1010
func main() {
1111
// configファイルがあるかどうかを確認
12-
_, err := os.Stat("config.yaml")
12+
homePath := os.Getenv("HOME")
13+
14+
_, err := os.Stat(homePath + "/.commitify/config.yaml")
1315
if os.IsNotExist(err) {
14-
if _, err := os.Create("config.yaml"); err != nil {
16+
if err := os.MkdirAll(homePath+"/.commitify", 0755); err != nil {
17+
fmt.Printf("error of make directory, %v", err)
18+
}
19+
if _, err := os.Create(homePath + "/.commitify/config.yaml"); err != nil {
1520
fmt.Printf("error creating config file, %s", err.Error())
1621
}
1722
}

0 commit comments

Comments
 (0)