mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-15 13:17:53 -08:00
fix(node): invert .Mismatch logic
This commit is contained in:
parent
32ee6fa7ab
commit
448bbd302f
|
@ -140,8 +140,13 @@ func (l *language) Enabled() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.matchesVersionFile != nil {
|
if l.matchesVersionFile != nil {
|
||||||
l.version.Expected, l.Mismatch = l.matchesVersionFile()
|
expected, match := l.matchesVersionFile()
|
||||||
|
if !match {
|
||||||
|
l.Mismatch = true
|
||||||
|
l.Expected = expected
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return enabled
|
return enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,31 @@ func TestLanguageEnabledOneExtensionFound(t *testing.T) {
|
||||||
assert.Equal(t, "unicorn", lang.Executable, "unicorn was used")
|
assert.Equal(t, "unicorn", lang.Executable, "unicorn was used")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLanguageEnabledMismatch(t *testing.T) {
|
||||||
|
expectedVersion := "1.2.009"
|
||||||
|
|
||||||
|
args := &languageArgs{
|
||||||
|
commands: []*cmd{
|
||||||
|
{
|
||||||
|
executable: "unicorn",
|
||||||
|
args: []string{"--version"},
|
||||||
|
regex: "(?P<version>.*)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extensions: []string{uni, corn},
|
||||||
|
enabledExtensions: []string{uni},
|
||||||
|
enabledCommands: []string{"unicorn"},
|
||||||
|
version: universion,
|
||||||
|
matchesVersionFile: func() (string, bool) {
|
||||||
|
return expectedVersion, false
|
||||||
|
},
|
||||||
|
}
|
||||||
|
lang := bootStrapLanguageTest(args)
|
||||||
|
assert.True(t, lang.Enabled())
|
||||||
|
assert.Equal(t, expectedVersion, lang.Expected, "the expected unicorn version is 1.2.009")
|
||||||
|
assert.True(t, lang.Mismatch, "we require a different version of unicorn")
|
||||||
|
}
|
||||||
|
|
||||||
func TestLanguageDisabledInHome(t *testing.T) {
|
func TestLanguageDisabledInHome(t *testing.T) {
|
||||||
args := &languageArgs{
|
args := &languageArgs{
|
||||||
commands: []*cmd{
|
commands: []*cmd{
|
||||||
|
|
|
@ -10,16 +10,18 @@ Display the currently active [Node.js][node-js] version.
|
||||||
|
|
||||||
## Sample Configuration
|
## Sample Configuration
|
||||||
|
|
||||||
import Config from '@site/src/components/Config.js';
|
import Config from "@site/src/components/Config.js";
|
||||||
|
|
||||||
<Config data={{
|
<Config
|
||||||
"type": "node",
|
data={{
|
||||||
"style": "powerline",
|
type: "node",
|
||||||
"powerline_symbol": "\uE0B0",
|
style: "powerline",
|
||||||
"foreground": "#ffffff",
|
powerline_symbol: "\uE0B0",
|
||||||
"background": "#6CA35E",
|
foreground: "#ffffff",
|
||||||
"template": " \uE718 {{ .Full }} "
|
background: "#6CA35E",
|
||||||
}}/>
|
template: " \uE718 {{ .Full }} ",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ import Config from '@site/src/components/Config.js';
|
||||||
| `.URL` | `string` | URL of the version info / release notes |
|
| `.URL` | `string` | URL of the version info / release notes |
|
||||||
| `.Error` | `string` | error encountered when fetching the version string |
|
| `.Error` | `string` | error encountered when fetching the version string |
|
||||||
| `.PackageManagerIcon` | `string` | the Yarn or NPM icon when setting `fetch_package_manager` to `true` |
|
| `.PackageManagerIcon` | `string` | the Yarn or NPM icon when setting `fetch_package_manager` to `true` |
|
||||||
| `.Mismatch` | `boolean` | if the version in `.nvmrc` matches with `.Full` |
|
| `.Mismatch` | `boolean` | true if the version in `.nvmrc` is not equal to `.Full` |
|
||||||
| `.Expected` | `string` | the expected version set in `.nvmrc` |
|
| `.Expected` | `string` | the expected version set in `.nvmrc` |
|
||||||
|
|
||||||
[go-text-template]: https://golang.org/pkg/text/template/
|
[go-text-template]: https://golang.org/pkg/text/template/
|
||||||
|
|
Loading…
Reference in a new issue