mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-22 00:21:11 -08:00
0d9eaa2a09
dotnet + node + npm + php + python url helper: returns plain text if url is empty instead of failing
35 lines
714 B
Go
35 lines
714 B
Go
package segments
|
|
|
|
import (
|
|
"oh-my-posh/environment"
|
|
"oh-my-posh/properties"
|
|
)
|
|
|
|
type Npm struct {
|
|
language
|
|
}
|
|
|
|
func (n *Npm) Enabled() bool {
|
|
return n.language.Enabled()
|
|
}
|
|
|
|
func (n *Npm) Template() string {
|
|
return " \ue71e {{.Full}} "
|
|
}
|
|
|
|
func (n *Npm) Init(props properties.Properties, env environment.Environment) {
|
|
n.language = language{
|
|
env: env,
|
|
props: props,
|
|
extensions: []string{"package.json", "package-lock.json"},
|
|
commands: []*cmd{
|
|
{
|
|
executable: "npm",
|
|
args: []string{"--version"},
|
|
regex: `(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
|
|
},
|
|
},
|
|
versionURLTemplate: "https://github.com/npm/cli/releases/tag/v{{ .Full }}",
|
|
}
|
|
}
|