mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -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 {
|
||||
l.version.Expected, l.Mismatch = l.matchesVersionFile()
|
||||
expected, match := l.matchesVersionFile()
|
||||
if !match {
|
||||
l.Mismatch = true
|
||||
l.Expected = expected
|
||||
}
|
||||
}
|
||||
|
||||
return enabled
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,31 @@ func TestLanguageEnabledOneExtensionFound(t *testing.T) {
|
|||
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) {
|
||||
args := &languageArgs{
|
||||
commands: []*cmd{
|
||||
|
|
|
@ -10,16 +10,18 @@ Display the currently active [Node.js][node-js] version.
|
|||
|
||||
## Sample Configuration
|
||||
|
||||
import Config from '@site/src/components/Config.js';
|
||||
import Config from "@site/src/components/Config.js";
|
||||
|
||||
<Config data={{
|
||||
"type": "node",
|
||||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#ffffff",
|
||||
"background": "#6CA35E",
|
||||
"template": " \uE718 {{ .Full }} "
|
||||
}}/>
|
||||
<Config
|
||||
data={{
|
||||
type: "node",
|
||||
style: "powerline",
|
||||
powerline_symbol: "\uE0B0",
|
||||
foreground: "#ffffff",
|
||||
background: "#6CA35E",
|
||||
template: " \uE718 {{ .Full }} ",
|
||||
}}
|
||||
/>
|
||||
|
||||
## Properties
|
||||
|
||||
|
@ -55,7 +57,7 @@ import Config from '@site/src/components/Config.js';
|
|||
| `.URL` | `string` | URL of the version info / release notes |
|
||||
| `.Error` | `string` | error encountered when fetching the version string |
|
||||
| `.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` |
|
||||
|
||||
[go-text-template]: https://golang.org/pkg/text/template/
|
||||
|
|
Loading…
Reference in a new issue