mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -08:00
fix(config): support jsonc
This commit is contained in:
parent
414581cf68
commit
9686b32ffa
|
@ -132,7 +132,6 @@ func loadConfig(env platform.Environment) *Config {
|
|||
cfg.Format = strings.TrimPrefix(filepath.Ext(configFile), ".")
|
||||
cfg.env = env
|
||||
|
||||
// read the data
|
||||
data, err := os.ReadFile(configFile)
|
||||
if err != nil {
|
||||
env.DebugF("error reading config file: %s", err)
|
||||
|
@ -144,13 +143,13 @@ func loadConfig(env platform.Environment) *Config {
|
|||
cfg.Format = YAML
|
||||
err = yaml.Unmarshal(data, &cfg)
|
||||
case "jsonc", "json":
|
||||
cfg.Format = JSON
|
||||
|
||||
if cfg.Format == "jsonc" {
|
||||
str := jsonutil.StripComments(string(data))
|
||||
data = []byte(str)
|
||||
}
|
||||
|
||||
cfg.Format = JSON
|
||||
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
err = decoder.Decode(&cfg)
|
||||
case "toml", "tml":
|
||||
|
|
Loading…
Reference in a new issue