fix: override config on init

resolves #2180
This commit is contained in:
Jan De Dobbeleer 2022-04-28 20:10:43 +02:00 committed by Jan De Dobbeleer
parent 8e1902b4de
commit 64196fe6ad
2 changed files with 2 additions and 21 deletions

2
.vscode/launch.json vendored
View file

@ -11,7 +11,7 @@
"prompt", "prompt",
"print", "print",
"primary", "primary",
"--config=${workspaceRoot}/themes/cinnamon.omp.json", "--config=https://gist.githubusercontent.com/ehawman-rosenberg/50b3b695526f03690cfd396d02c2cca3/raw/c2e0bc78cdf551b0cc76f593e4fd70428f981c0e/eh-tea.omp.json",
"--shell=pwsh", "--shell=pwsh",
"--terminal-width=200", "--terminal-width=200",
] ]

View file

@ -257,26 +257,7 @@ func (env *ShellEnvironment) resolveConfigPath() {
} }
func (env *ShellEnvironment) downloadConfig(location string) error { func (env *ShellEnvironment) downloadConfig(location string) error {
configFileName := fmt.Sprintf("%s.omp.json", env.Version) configPath := filepath.Join(env.CachePath(), "config.omp.json")
configPath := filepath.Join(env.CachePath(), configFileName)
if env.HasFilesInDir(env.CachePath(), configFileName) {
env.CmdFlags.Config = configPath
return nil
}
// clean old config files
cleanCacheDir := func() {
dir, err := ioutil.ReadDir(env.CachePath())
if err != nil {
return
}
for _, file := range dir {
if strings.HasSuffix(file.Name(), ".omp.json") {
os.Remove(filepath.Join(env.CachePath(), file.Name()))
}
}
}
cleanCacheDir()
cfg, err := env.HTTPRequest(location, 5000) cfg, err := env.HTTPRequest(location, 5000)
if err != nil { if err != nil {
return err return err