Skip to content

Commit

Permalink
Use configdir
Browse files Browse the repository at this point in the history
Refs tursodatabase/turso-cli#876

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
  • Loading branch information
haaawk committed Jun 26, 2024
1 parent 6cff49f commit 3de6985
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/fatih/color v1.14.1
github.com/frankban/quicktest v1.14.4
github.com/go-playground/validator/v10 v10.11.2
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/knadh/koanf/parsers/yaml v0.1.0
github.com/knadh/koanf/providers/env v0.1.0
github.com/knadh/koanf/providers/file v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU=
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0=
github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs=
github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI=
github.com/knadh/koanf/parsers/yaml v0.1.0 h1:ZZ8/iGfRLvKSaMEECEBPM1HQslrZADk8fP1XFUxVI5w=
Expand Down
3 changes: 2 additions & 1 deletion internal/shell/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package shell

import (
"fmt"
"github.com/kirsle/configdir"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -35,7 +36,7 @@ func getHistoryFileName(name string) string {
}

func getHistoryFolderPath(historyName string) string {
path := filepath.Join(os.Getenv("HOME"), fmt.Sprintf(".%s", historyName))
path := filepath.Join(configdir.LocalConfig("turso"), fmt.Sprintf(".%s", historyName))
_ = os.MkdirAll(path, os.ModePerm)
return path
}
Expand Down
4 changes: 2 additions & 2 deletions internal/shell/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package shell_test

import (
"fmt"
"os"
"github.com/kirsle/configdir"
"testing"

qt "github.com/frankban/quicktest"
Expand All @@ -15,7 +15,7 @@ const historyName = "libsql"
var sharedHistoryFileName = fmt.Sprintf(".%s_shell_history", historyName)

func getExpectedHistoryFullPath(name string) string {
return fmt.Sprintf("%s/.%s/.%s_shell_history", os.Getenv("HOME"), historyName, name)
return fmt.Sprintf("%s/.%s/.%s_shell_history", configdir.LocalConfig("turso"), historyName, name)
}

func TestGetHistoryFileBasedOnMode_GivenLocalHistory_WhenPathIsEmpty_ExpectSharedLocalHistory(t *testing.T) {
Expand Down

0 comments on commit 3de6985

Please sign in to comment.