feat(config): parse jsonc config files

resolves #4097
This commit is contained in:
Jan De Dobbeleer 2023-07-27 13:19:15 +02:00 committed by Jan De Dobbeleer
parent 344c9b6d86
commit 3a580ff122
2 changed files with 10 additions and 4 deletions

View file

@ -133,12 +133,17 @@ func loadConfig(env platform.Environment) *Config {
cfg.origin = configFile cfg.origin = configFile
cfg.Format = strings.TrimPrefix(filepath.Ext(configFile), ".") cfg.Format = strings.TrimPrefix(filepath.Ext(configFile), ".")
cfg.env = env cfg.env = env
if cfg.Format == "yml" {
// support different extensions
switch cfg.Format {
case "yml":
cfg.Format = YAML cfg.Format = YAML
case "jsonc":
cfg.Format = JSON
} }
config.AddDriver(yaml.Driver) config.AddDriver(yaml.Driver.WithAliases("yaml", "yml"))
config.AddDriver(json.Driver) config.AddDriver(json.Driver.WithAliases("json", "jsonc"))
config.AddDriver(toml.Driver) config.AddDriver(toml.Driver)
if config.Default().IsEmpty() { if config.Default().IsEmpty() {

View file

@ -632,9 +632,10 @@ func (env *Shell) Flags() *Flags {
func (env *Shell) Shell() string { func (env *Shell) Shell() string {
defer env.Trace(time.Now()) defer env.Trace(time.Now())
if env.CmdFlags.Shell != "" { if len(env.CmdFlags.Shell) != 0 {
return env.CmdFlags.Shell return env.CmdFlags.Shell
} }
env.Debug("no shell name provided in flags, trying to detect it")
pid := os.Getppid() pid := os.Getppid()
p, _ := process.NewProcess(int32(pid)) p, _ := process.NewProcess(int32(pid))
name, err := p.Name() name, err := p.Name()