mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
refactor: strip .exe from shell names
This commit is contained in:
parent
401c5b3265
commit
2603ff51bf
|
@ -1,5 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
type shell struct {
|
type shell struct {
|
||||||
props *properties
|
props *properties
|
||||||
env environmentInfo
|
env environmentInfo
|
||||||
|
@ -15,7 +17,8 @@ func (s *shell) string() string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
return p.Executable()
|
shell := strings.Replace(p.Executable(), ".exe", "", 1)
|
||||||
|
return shell
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *shell) init(props *properties, env environmentInfo) {
|
func (s *shell) init(props *properties, env environmentInfo) {
|
||||||
|
|
|
@ -42,7 +42,22 @@ func TestWriteCurrentShell(t *testing.T) {
|
||||||
env: env,
|
env: env,
|
||||||
props: props,
|
props: props,
|
||||||
}
|
}
|
||||||
assert.Equal(t, "zsh", s.string())
|
assert.Equal(t, expected, s.string())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteCurrentShellWindowsExe(t *testing.T) {
|
||||||
|
expected := "pwsh"
|
||||||
|
env := new(MockedEnvironment)
|
||||||
|
process := new(process)
|
||||||
|
parentProcess := expected + ".exe"
|
||||||
|
process.On("Executable", nil).Return(parentProcess)
|
||||||
|
env.On("getParentProcess", nil).Return(process, nil)
|
||||||
|
props := &properties{}
|
||||||
|
s := &shell{
|
||||||
|
env: env,
|
||||||
|
props: props,
|
||||||
|
}
|
||||||
|
assert.Equal(t, expected, s.string())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteCurrentShellError(t *testing.T) {
|
func TestWriteCurrentShellError(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue