Skip to content

Commit

Permalink
feat(config): parse jsonc config files
Browse files Browse the repository at this point in the history
resolves #4097
  • Loading branch information
JanDeDobbeleer committed Jul 27, 2023
1 parent 344c9b6 commit 3a580ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ func loadConfig(env platform.Environment) *Config {
cfg.origin = configFile
cfg.Format = strings.TrimPrefix(filepath.Ext(configFile), ".")
cfg.env = env
if cfg.Format == "yml" {

// support different extensions
switch cfg.Format {
case "yml":
cfg.Format = YAML
case "jsonc":
cfg.Format = JSON
}

config.AddDriver(yaml.Driver)
config.AddDriver(json.Driver)
config.AddDriver(yaml.Driver.WithAliases("yaml", "yml"))
config.AddDriver(json.Driver.WithAliases("json", "jsonc"))
config.AddDriver(toml.Driver)

if config.Default().IsEmpty() {
Expand Down
3 changes: 2 additions & 1 deletion src/platform/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,10 @@ func (env *Shell) Flags() *Flags {

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

0 comments on commit 3a580ff

Please sign in to comment.