feat: enhance Node.js environment configuration in task runner

- Added a new utility function GetNodeBinPath to retrieve the global node_bin path from configuration, with a default fallback.
- Updated configureNodePath method to set the PATH environment variable to include the node_bin path if it's not already present, improving the task runner's environment setup for Node.js development.
This commit is contained in:
Marvin Zhang
2025-04-15 21:00:53 +08:00
parent 7caa0127dc
commit e534a12a11
2 changed files with 14 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ const (
MetadataConfigName = "config.json"
DefaultPyenvPath = "/root/.pyenv"
DefaultNodeModulesPath = "/usr/lib/node_modules"
DefaultNodeBinPath = "/usr/lib/bin"
DefaultGoPath = "/root/go"
)
@@ -271,6 +272,13 @@ func GetNodeModulesPath() string {
return DefaultNodeModulesPath
}
func GetNodeBinPath() string {
if res := viper.GetString("install.node.bin"); res != "" {
return res
}
return DefaultNodeBinPath
}
func GetGoPath() string {
if res := viper.GetString("install.go.path"); res != "" {
return res