Skip to content

Commit

Permalink
chore: initialize config path cache correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Apr 8, 2024
1 parent 6771ffd commit 1e4a117
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ var (
)

func LoadConfig(configPath string) (*Aliae, error) {
configPath = resolveConfigPath(configPath)
configPathCache = resolveConfigPath(configPath)

if strings.HasPrefix(configPath, "http://") || strings.HasPrefix(configPath, "https://") {
return getRemoteConfig(configPath)
if strings.HasPrefix(configPathCache, "http://") || strings.HasPrefix(configPathCache, "https://") {
return getRemoteConfig(configPathCache)
}

if filepath, err := os.Stat(configPath); os.IsNotExist(err) || filepath.IsDir() {
return nil, fmt.Errorf("Config file not found: %s", configPath)
if filepath, err := os.Stat(configPathCache); os.IsNotExist(err) || filepath.IsDir() {
return nil, fmt.Errorf("Config file not found: %s", configPathCache)
}

data, _ := os.ReadFile(configPath)
data, _ := os.ReadFile(configPathCache)

return parseConfig(data)
}
Expand Down Expand Up @@ -73,8 +73,6 @@ func resolveConfigPath(configPath string) string {
configPath = path.Join(home(), ".aliae.yaml")
}

configPathCache = configPath

return configPath
}

Expand Down

0 comments on commit 1e4a117

Please sign in to comment.