chore: fix shell exec node path

This commit is contained in:
engigu
2026-03-23 22:26:34 +08:00
parent eb142bf751
commit a87a835b5f
4 changed files with 1496 additions and 342 deletions
+13 -1
View File
@@ -19,7 +19,7 @@ func GetMiseNodePath(version string) string {
}
cmd := exec.Command("mise", "where", "node@"+version)
out, err := cmd.Output()
out, err := cmd.CombinedOutput()
if err == nil {
nodeDir := strings.TrimSpace(string(out))
if nodeDir != "" {
@@ -32,6 +32,18 @@ func GetMiseNodePath(version string) string {
return ""
}
// InjectNodePath 检查语言环境中是否有 node,如果有则自动获取并注入 NODE_PATH 到环境变量切片中
func InjectNodePath(envs *[]string, languages []map[string]string) {
for _, lang := range languages {
if lang["name"] == "node" {
if nodePath := GetMiseNodePath(lang["version"]); nodePath != "" {
*envs = append(*envs, "NODE_PATH="+nodePath)
}
break
}
}
}
// BuildMiseCommand 构建多语言 mise 执行命令 (字符串形式)
func BuildMiseCommand(command string, languages []map[string]string) string {
if len(languages) == 0 {