2020-09-17 07:43:45 -07:00
|
|
|
package main
|
|
|
|
|
2020-10-01 11:57:02 -07:00
|
|
|
type node struct {
|
2020-09-17 07:43:45 -07:00
|
|
|
props *properties
|
|
|
|
env environmentInfo
|
|
|
|
nodeVersion string
|
|
|
|
}
|
|
|
|
|
2020-10-09 06:49:08 -07:00
|
|
|
const (
|
|
|
|
//DisplayVersion show the version number or not
|
|
|
|
DisplayVersion Property = "display_version"
|
|
|
|
)
|
|
|
|
|
2020-10-01 11:57:02 -07:00
|
|
|
func (n *node) string() string {
|
2020-10-09 06:49:08 -07:00
|
|
|
if n.props.getBool(DisplayVersion, true) {
|
|
|
|
return n.nodeVersion
|
|
|
|
}
|
|
|
|
return ""
|
2020-09-17 07:43:45 -07:00
|
|
|
}
|
|
|
|
|
2020-10-01 11:57:02 -07:00
|
|
|
func (n *node) init(props *properties, env environmentInfo) {
|
2020-09-17 07:43:45 -07:00
|
|
|
n.props = props
|
|
|
|
n.env = env
|
|
|
|
}
|
|
|
|
|
2020-10-01 11:57:02 -07:00
|
|
|
func (n *node) enabled() bool {
|
|
|
|
if !n.env.hasFiles("*.js") && !n.env.hasFiles("*.ts") {
|
|
|
|
return false
|
|
|
|
}
|
2020-09-17 07:43:45 -07:00
|
|
|
if !n.env.hasCommand("node") {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
n.nodeVersion = n.env.runCommand("node", "--version")
|
|
|
|
return true
|
|
|
|
}
|