Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
lpxxn committed Jun 30, 2021
1 parent 8e0761f commit 268401e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func (a *AppConfig) parseCmdConfig() error {
}
return nil
}

func configNotExist() error {
return NotExistErr
}
7 changes: 3 additions & 4 deletions config/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"

"github.com/BurntSushi/toml"
"github.com/lpxxn/doraemon/internal"
"github.com/skratchdot/open-golang/open"
)

Expand Down Expand Up @@ -45,10 +46,8 @@ func ConfDir() string {
panic(err)
}
dirPath := path.Join(rootDir, confDirName)
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
if err = os.MkdirAll(dirPath, os.ModePerm); err != nil {
panic(err)
}
if err := internal.MakeFolder(dirPath, os.ModePerm); err != nil {
panic(err)
}
return dirPath
}
Expand Down
9 changes: 9 additions & 0 deletions internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"fmt"
"os"
)

type Color string
Expand Down Expand Up @@ -67,3 +68,11 @@ func SendMsg(startWithNewLine bool, caption, text string, color Color, endWithNe
fmt.Println(startNewLine + BeautifyText(caption, color) + " " + text + endNewLine) // colorized text
}
}

func MakeFolder(folderName string, chmod os.FileMode) error {
if _, err := os.Stat(folderName); os.IsNotExist(err) {
return os.MkdirAll(folderName, chmod)
} else {
return err
}
}

0 comments on commit 268401e

Please sign in to comment.