Skip to content

Commit 3de6985

Browse files
committed
Use configdir
Refs tursodatabase/turso-cli#876 Signed-off-by: Piotr Jastrzebski <[email protected]>
1 parent 6cff49f commit 3de6985

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/fatih/color v1.14.1
1010
github.com/frankban/quicktest v1.14.4
1111
github.com/go-playground/validator/v10 v10.11.2
12+
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
1213
github.com/knadh/koanf/parsers/yaml v0.1.0
1314
github.com/knadh/koanf/providers/env v0.1.0
1415
github.com/knadh/koanf/providers/file v0.1.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
3030
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
3131
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3232
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
33+
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU=
34+
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0=
3335
github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs=
3436
github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI=
3537
github.com/knadh/koanf/parsers/yaml v0.1.0 h1:ZZ8/iGfRLvKSaMEECEBPM1HQslrZADk8fP1XFUxVI5w=

internal/shell/history.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package shell
22

33
import (
44
"fmt"
5+
"github.com/kirsle/configdir"
56
"net/url"
67
"os"
78
"path/filepath"
@@ -35,7 +36,7 @@ func getHistoryFileName(name string) string {
3536
}
3637

3738
func getHistoryFolderPath(historyName string) string {
38-
path := filepath.Join(os.Getenv("HOME"), fmt.Sprintf(".%s", historyName))
39+
path := filepath.Join(configdir.LocalConfig("turso"), fmt.Sprintf(".%s", historyName))
3940
_ = os.MkdirAll(path, os.ModePerm)
4041
return path
4142
}

internal/shell/history_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package shell_test
22

33
import (
44
"fmt"
5-
"os"
5+
"github.com/kirsle/configdir"
66
"testing"
77

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

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

2121
func TestGetHistoryFileBasedOnMode_GivenLocalHistory_WhenPathIsEmpty_ExpectSharedLocalHistory(t *testing.T) {

0 commit comments

Comments
 (0)