mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
5844faa54d
New segment for .NET SDK version (or unsupported version) display. Includes update for handling command execution errors so segments can act differently based on exit codes. Using a custom error type to make it testable rather than passing the OS error directly to the segment.
31 lines
552 B
Go
31 lines
552 B
Go
package main
|
|
|
|
type node struct {
|
|
props *properties
|
|
env environmentInfo
|
|
nodeVersion string
|
|
}
|
|
|
|
func (n *node) string() string {
|
|
if n.props.getBool(DisplayVersion, true) {
|
|
return n.nodeVersion
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (n *node) init(props *properties, env environmentInfo) {
|
|
n.props = props
|
|
n.env = env
|
|
}
|
|
|
|
func (n *node) enabled() bool {
|
|
if !n.env.hasFiles("*.js") && !n.env.hasFiles("*.ts") {
|
|
return false
|
|
}
|
|
if !n.env.hasCommand("node") {
|
|
return false
|
|
}
|
|
n.nodeVersion, _ = n.env.runCommand("node", "--version")
|
|
return true
|
|
}
|