oh-my-posh/segment_node.go
Travis Illig 5844faa54d feat: dotnet segment for .NET SDK display
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.
2020-10-16 11:39:01 -07:00

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
}