diff --git a/CHANGELOG.md b/CHANGELOG.md index 5643993e..0ab08993 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project are documented in this file. +## [Unreleased] + +### Fixed + +- **m87 全局安装探测测试(Windows)**:`exists` mock 用 `path.includes("\\")` 猜平台。win32 上 `path.join("/usr/lib/node_modules", …)` 仍含反斜杠,POSIX 用例被当成 Windows 路径比较,导致 `found` 为 undefined、`validate-platforms (windows-latest)` 失败。现按用例传入明确 npm root。 + ## [1.19.2] - 2026-09-15 ### Fixed — 跨平台加固(Windows / Linux / macOS) diff --git a/tests/m87-zcode-host.test.ts b/tests/m87-zcode-host.test.ts index a250da3f..383278c8 100644 --- a/tests/m87-zcode-host.test.ts +++ b/tests/m87-zcode-host.test.ts @@ -174,16 +174,21 @@ describe("M87 ZCode host", () => { const expected = (root: string) => join(root, "@roarpeng", "graphflow", "dist", "surfaces", "mcp", "server.js"); // BOM + CRLF (Windows npm), banner line before the path, blank lines. - for (const raw of [ - "\uFEFFC:\\npm\\node_modules\r\n", - "npm warn config\r\n\r\nC:\\npm\\node_modules\r\n", - "\n\n/usr/lib/node_modules\n\n", + // Pass the npm root per case — do not guess from `path.includes("\\")`. + // On win32, `path.join("/usr/lib/node_modules", ...)` still contains + // backslashes, so that heuristic treats a POSIX root as a Windows path + // and the mock `exists` returns false (`found` undefined). + for (const { raw, root } of [ + { raw: "\uFEFFC:\\npm\\node_modules\r\n", root: "C:\\npm\\node_modules" }, + { raw: "npm warn config\r\n\r\nC:\\npm\\node_modules\r\n", root: "C:\\npm\\node_modules" }, + { raw: "\n\n/usr/lib/node_modules\n\n", root: "/usr/lib/node_modules" }, ]) { const found = resolveGlobalGraphflowInstall({ runNpmRoot: () => raw, - exists: (p) => p === expected(p.includes("\\") ? "C:\\npm\\node_modules" : "/usr/lib/node_modules"), + exists: (p) => p === expected(root), }); expect(found).toBeDefined(); + expect(found?.runtimeRoot).toBe(join(root, "@roarpeng", "graphflow")); } });