Skip to content

Commit

Permalink
rename the configuration to direnv.toml (#498)
Browse files Browse the repository at this point in the history
it was confusing that the man page and configuration name weren't the
same. Keep config.toml around for back-compate.

see also #180 (comment)
  • Loading branch information
zimbatm committed May 21, 2019
1 parent 4d99f12 commit 54cb3c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,21 @@ func LoadConfig(env Env) (config *Config, err error) {
config.WhitelistPrefix = make([]string, 0)
config.WhitelistExact = make(map[string]bool)

// Load the config.toml
// Load the TOML config
config.TomlPath = filepath.Join(config.ConfDir, "direnv.toml")
if _, statErr := os.Stat(config.TomlPath); statErr != nil {
config.TomlPath = ""
}

config.TomlPath = filepath.Join(config.ConfDir, "config.toml")
if _, statErr := os.Stat(config.TomlPath); statErr == nil {
if _, statErr := os.Stat(config.TomlPath); statErr != nil {
config.TomlPath = ""
}

if config.TomlPath != "" {
var tomlConf tomlConfig
if _, err = toml.DecodeFile(config.TomlPath, &tomlConf); err != nil {
err = fmt.Errorf("LoadConfig() failed to parse config.toml: %q", err)
err = fmt.Errorf("LoadConfig() failed to parse %s: %q", config.TomlPath, err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion man/direnv.toml.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ direnv.toml - the direnv configuration file
DESCRIPTION
-----------

A configuration file in [TOML](https://github.com/toml-lang/toml) format to specify a variety of configuration options for direnv. Resides at CONFIGURATION_DIR/config.toml. For many users, this will be located at $HOME/.config/direnv/config.toml.
A configuration file in [TOML](https://github.com/toml-lang/toml) format to specify a variety of configuration options for direnv. Resides at CONFIGURATION_DIR/direnv.toml. For many users, this will be located at $HOME/.config/direnv/direnv.toml.

FORMAT
------
Expand Down

0 comments on commit 54cb3c5

Please sign in to comment.