Files
Local-Cursor/internal/cursor/localize_windows_test.go
FuDie0915 db73cf5a39 chore: import Local-Cursor v1.1.8 source snapshot
Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
2026-11-10 01:24:28 +08:00

40 lines
1.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build windows
package cursor
import (
"os"
"path/filepath"
"strings"
"testing"
)
// 验证:注册表 PATH 中的 fnm\bin(仅含 fnm.exe)能被扩展到实际 node 所在目录。
func TestMergeNodeSearchPathFindsNode(t *testing.T) {
merged, _ := mergeNodeSearchPath()
if _, err := execLookPathIn(merged, "node.exe"); err != nil {
t.Fatalf("node.exe not found in merged PATH: %v", err)
}
}
// execLookPathIn 在给定 PATH 字符串下查找可执行文件。
func execLookPathIn(pathEnv string, file string) (string, error) {
for _, dir := range filepath.SplitList(pathEnv) {
if dir == "" {
continue
}
candidate := filepath.Join(dir, file)
if info, err := os.Stat(candidate); err == nil && !info.IsDir() {
return candidate, nil
}
// .cmd/.bat 等 PATHEXT 场景只处理精确名与 .cmd。
if !strings.HasSuffix(strings.ToLower(file), ".exe") {
cmdCandidate := candidate + ".cmd"
if info, err := os.Stat(cmdCandidate); err == nil && !info.IsDir() {
return cmdCandidate, nil
}
}
}
return "", os.ErrNotExist
}