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-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
|
|
|
|
}
|
2020-10-16 08:43:02 -07:00
|
|
|
n.nodeVersion, _ = n.env.runCommand("node", "--version")
|
2020-09-17 07:43:45 -07:00
|
|
|
return true
|
|
|
|
}
|