mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-09-19 21:17:31 -07:00
refactor: strip .exe from shell names
This commit is contained in:
parent
401c5b3265
commit
2603ff51bf
|
@ -1,5 +1,7 @@
|
|||
package main
|
||||
|
||||
import "strings"
|
||||
|
||||
type shell struct {
|
||||
props *properties
|
||||
env environmentInfo
|
||||
|
@ -15,7 +17,8 @@ func (s *shell) string() string {
|
|||
if err != nil {
|
||||
return "unknown"
|
||||
}
|
||||
return p.Executable()
|
||||
shell := strings.Replace(p.Executable(), ".exe", "", 1)
|
||||
return shell
|
||||
}
|
||||
|
||||
func (s *shell) init(props *properties, env environmentInfo) {
|
||||
|
|
|
@ -42,7 +42,22 @@ func TestWriteCurrentShell(t *testing.T) {
|
|||
env: env,
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue