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
This commit is contained in:
39
internal/cursor/localize_windows_test.go
Normal file
39
internal/cursor/localize_windows_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
//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
|
||||
}
|
||||
Reference in New Issue
Block a user