Skip to content

Commit

Permalink
👔 up(sys): rename a internal func and update some call name
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Mar 16, 2023
1 parent 5221781 commit 17aeb31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 2 additions & 4 deletions internal/comfunc/sysfunc.go
Expand Up @@ -8,8 +8,8 @@ import (
"strings"
)

// ExpandPath will parse first `~` as user home dir path.
func ExpandPath(pathStr string) string {
// ExpandHome will parse first `~` as user home dir path.
func ExpandHome(pathStr string) string {
if len(pathStr) == 0 {
return pathStr
}
Expand All @@ -26,7 +26,6 @@ func ExpandPath(pathStr string) string {
if err != nil {
return pathStr
}

return homeDir + pathStr[1:]
}

Expand Down Expand Up @@ -106,6 +105,5 @@ func HasShellEnv(shell string) bool {
if err != nil {
return false
}

return strings.TrimSpace(out) == "OK"
}
7 changes: 4 additions & 3 deletions sysutil/user.go
Expand Up @@ -76,6 +76,7 @@ func UserConfigDir(subPath string) string {
}

// ExpandPath will parse `~` as user home dir path.
func ExpandPath(path string) string {
return comfunc.ExpandPath(path)
}
func ExpandPath(path string) string { return comfunc.ExpandHome(path) }

// ExpandHome will parse `~` as user home dir path.
func ExpandHome(path string) string { return comfunc.ExpandHome(path) }
1 change: 1 addition & 0 deletions sysutil/user_test.go
Expand Up @@ -34,6 +34,7 @@ func TestUserDir(t *testing.T) {

rawPath := "~/.kite"
assert.LenGt(t, sysutil.ExpandPath(rawPath), len(rawPath))
assert.Neq(t, rawPath, sysutil.ExpandHome(rawPath))
}

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

0 comments on commit 17aeb31

Please sign in to comment.