Skip to content

Commit

Permalink
fix: don't error on missing default files
Browse files Browse the repository at this point in the history
The default `.vale.ini` isn't created or required, so we can simply ignore
the error if it's not found. The default `StylesPath` *should* be created,
but the error is now only raised by the `ls-dirs` command.
  • Loading branch information
jdkato committed Jan 11, 2024
1 parent e00ffbd commit 3c13689
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
14 changes: 3 additions & 11 deletions internal/core/config.go
Expand Up @@ -176,12 +176,8 @@ func NewConfig(flags *CLIFlags) (*Config, error) {
cfg.Paths = []string{""}
cfg.ConfigFiles = []string{}

found, err := DefaultStylesPath()
if err != nil {
return &cfg, err
}

if !flags.IgnoreGlobal {
found, _ := DefaultStylesPath()
if !flags.IgnoreGlobal && IsDir(found) {
cfg.StylesPath = found
cfg.Paths = []string{found}
}
Expand Down Expand Up @@ -242,11 +238,7 @@ func GetStylesPath(src string) (string, error) {
if err != nil {
return "", err
}

fallback, err := DefaultStylesPath()
if err != nil {
return "", err
}
fallback, _ := DefaultStylesPath()

core := uCfg.Section("")
return core.Key("StylesPath").MustString(fallback), nil
Expand Down
5 changes: 1 addition & 4 deletions internal/core/source.go
Expand Up @@ -196,10 +196,7 @@ func loadINI(cfg *Config, dry bool) (*ini.File, error) {
//
// In other words, this config file is *always* loaded and is read after
// any other sources to allow for project-agnostic customization.
defaultCfg, err := DefaultConfig()
if err != nil {
return nil, err
}
defaultCfg, _ := DefaultConfig()

if FileExists(defaultCfg) && !cfg.Flags.IgnoreGlobal && !dry {
err = uCfg.Append(defaultCfg)
Expand Down

0 comments on commit 3c13689

Please sign in to comment.