mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(dotnet): correct exit code for different OS architectures
closes #819
This commit is contained in:
parent
3fd70ce716
commit
db1f6bb751
7
src/constants_unix.go
Normal file
7
src/constants_unix.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const (
|
||||||
|
dotnetExitCode = 142
|
||||||
|
)
|
8
src/constants_windows64.go
Normal file
8
src/constants_windows64.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// +build windows
|
||||||
|
// +build amd64
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const (
|
||||||
|
dotnetExitCode = int(0x80008091)
|
||||||
|
)
|
8
src/constrants_windows386.go
Normal file
8
src/constrants_windows386.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// +build windows
|
||||||
|
// +build 386
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const (
|
||||||
|
dotnetExitCode = -2147450735
|
||||||
|
)
|
|
@ -8,19 +8,13 @@ const (
|
||||||
// UnsupportedDotnetVersionIcon is displayed when the dotnet version in
|
// UnsupportedDotnetVersionIcon is displayed when the dotnet version in
|
||||||
// the current folder isn't supported by the installed dotnet SDK set.
|
// the current folder isn't supported by the installed dotnet SDK set.
|
||||||
UnsupportedDotnetVersionIcon Property = "unsupported_version_icon"
|
UnsupportedDotnetVersionIcon Property = "unsupported_version_icon"
|
||||||
|
|
||||||
dotnetExitCodeUnix = 145
|
|
||||||
dotnetExitCodeWindows = -2147450735
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *dotnet) string() string {
|
func (d *dotnet) string() string {
|
||||||
version := d.language.string()
|
version := d.language.string()
|
||||||
|
|
||||||
// Exit codes 145 and 0x80008091 are special indicators that dotnet
|
|
||||||
// ran, but the current project config settings specify
|
|
||||||
// use of an SDK that isn't installed.
|
|
||||||
exitCode := d.language.exitCode
|
exitCode := d.language.exitCode
|
||||||
if exitCode == dotnetExitCodeWindows || exitCode == dotnetExitCodeUnix {
|
if exitCode == dotnetExitCode {
|
||||||
return d.language.props.getString(UnsupportedDotnetVersionIcon, "\uf071 ")
|
return d.language.props.getString(UnsupportedDotnetVersionIcon, "\uf071 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,24 +71,10 @@ func TestDotnetVersionDisplayed(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDotnetVersionUnsupported(t *testing.T) {
|
func TestDotnetVersionUnsupported(t *testing.T) {
|
||||||
expected := "x"
|
|
||||||
args := &dotnetArgs{
|
args := &dotnetArgs{
|
||||||
enabled: true,
|
enabled: true,
|
||||||
displayVersion: true,
|
displayVersion: true,
|
||||||
exitCode: dotnetExitCodeUnix,
|
exitCode: dotnetExitCode,
|
||||||
unsupportedIcon: expected,
|
|
||||||
}
|
|
||||||
dotnet := bootStrapDotnetTest(args)
|
|
||||||
assert.True(t, dotnet.enabled())
|
|
||||||
assert.Equal(t, expected, dotnet.string())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDotnetVersionUnsupportedWindows(t *testing.T) {
|
|
||||||
expected := "x"
|
|
||||||
args := &dotnetArgs{
|
|
||||||
enabled: true,
|
|
||||||
displayVersion: true,
|
|
||||||
exitCode: dotnetExitCodeWindows,
|
|
||||||
unsupportedIcon: expected,
|
unsupportedIcon: expected,
|
||||||
}
|
}
|
||||||
dotnet := bootStrapDotnetTest(args)
|
dotnet := bootStrapDotnetTest(args)
|
||||||
|
|
Loading…
Reference in a new issue