mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
Export store.{ensureDataDir errEmptyHOME}
This commit is contained in:
parent
fd2e26700a
commit
f0c2bc11fb
|
@ -7,16 +7,16 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
errEmptyHOME = errors.New("Environment variable HOME is empty")
|
||||
ErrEmptyHOME = errors.New("Environment variable HOME is empty")
|
||||
)
|
||||
|
||||
// ensureDataDir ensures Elvish's data directory exists, creating it if
|
||||
// necessary. It returns the path to the data directory (never with a
|
||||
// trailing slash) and possible error.
|
||||
func ensureDataDir() (string, error) {
|
||||
func EnsureDataDir() (string, error) {
|
||||
home := os.Getenv("HOME")
|
||||
if home == "" {
|
||||
return "", errEmptyHOME
|
||||
return "", ErrEmptyHOME
|
||||
}
|
||||
home = strings.TrimRight(home, "/")
|
||||
ddir := home + "/.elvish"
|
||||
|
|
|
@ -16,7 +16,7 @@ var createTable = map[string]string{}
|
|||
|
||||
// DefaultDB returns the default database for storage.
|
||||
func DefaultDB() (*sql.DB, error) {
|
||||
ddir, err := ensureDataDir()
|
||||
ddir, err := EnsureDataDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user