mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -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.Format = strings.TrimPrefix(filepath.Ext(configFile), ".")
|
||||||
cfg.env = env
|
cfg.env = env
|
||||||
|
|
||||||
// read the data
|
|
||||||
data, err := os.ReadFile(configFile)
|
data, err := os.ReadFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.DebugF("error reading config file: %s", err)
|
env.DebugF("error reading config file: %s", err)
|
||||||
|
@ -144,13 +143,13 @@ func loadConfig(env platform.Environment) *Config {
|
||||||
cfg.Format = YAML
|
cfg.Format = YAML
|
||||||
err = yaml.Unmarshal(data, &cfg)
|
err = yaml.Unmarshal(data, &cfg)
|
||||||
case "jsonc", "json":
|
case "jsonc", "json":
|
||||||
cfg.Format = JSON
|
|
||||||
|
|
||||||
if cfg.Format == "jsonc" {
|
if cfg.Format == "jsonc" {
|
||||||
str := jsonutil.StripComments(string(data))
|
str := jsonutil.StripComments(string(data))
|
||||||
data = []byte(str)
|
data = []byte(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.Format = JSON
|
||||||
|
|
||||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||||
err = decoder.Decode(&cfg)
|
err = decoder.Decode(&cfg)
|
||||||
case "toml", "tml":
|
case "toml", "tml":
|
||||||
|
|
Loading…
Reference in a new issue