From c4dcfd5da0d5ac68131629f0ac5411ef593d5c94 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 9 Jul 2020 18:28:10 -0400 Subject: [PATCH] fix(config): add /etc/cheat config path Add `/etc/cheat/conf.yml` to default config paths. See #568 for context. --- cmd/cheat/main.go | 2 +- internal/config/paths.go | 2 +- internal/config/paths_test.go | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/cheat/main.go b/cmd/cheat/main.go index f910032..8cf8a39 100755 --- a/cmd/cheat/main.go +++ b/cmd/cheat/main.go @@ -17,7 +17,7 @@ import ( "github.com/cheat/cheat/internal/installer" ) -const version = "4.0.1" +const version = "4.0.2" func main() { diff --git a/internal/config/paths.go b/internal/config/paths.go index f333c1a..49f2342 100644 --- a/internal/config/paths.go +++ b/internal/config/paths.go @@ -36,10 +36,10 @@ func Paths( paths = append(paths, path.Join(xdgpath, "/cheat/conf.yml")) } - // if `XDG_CONFIG_HOME` is not set, search the user's home directory paths = append(paths, []string{ path.Join(home, ".config/cheat/conf.yml"), path.Join(home, ".cheat/conf.yml"), + "/etc/cheat/conf.yml", }...) return paths, nil diff --git a/internal/config/paths_test.go b/internal/config/paths_test.go index 4cb2cb9..0dd64f5 100644 --- a/internal/config/paths_test.go +++ b/internal/config/paths_test.go @@ -39,6 +39,7 @@ func TestValidatePathsNix(t *testing.T) { "/home/bar/cheat/conf.yml", "/home/foo/.config/cheat/conf.yml", "/home/foo/.cheat/conf.yml", + "/etc/cheat/conf.yml", } // assert that output matches expectations @@ -81,6 +82,7 @@ func TestValidatePathsNixNoXDG(t *testing.T) { want := []string{ "/home/foo/.config/cheat/conf.yml", "/home/foo/.cheat/conf.yml", + "/etc/cheat/conf.yml", } // assert that output matches expectations