fix(test): ps1-encoding 守卫改用 fileURLToPath(Windows 上 URL.pathname 会多一根前导斜杠)
**这是 Windows CI 一上线就抓到的真 bug** —— 新加的 CI 单测步骤当场回本。
根因:测试用 new URL('../../', import.meta.url).pathname 取仓库根。macOS 上得到
/Users/... 可用;Windows 上得到 /D:/a/nodeagent/...(盘符前多一根斜杠),
readdirSync 直接 ENOENT → 整个文件 22 个用例全灭。
本地(macOS)永远测不出来,只有 Windows runner 会炸。
修法:改用 fileURLToPath(new URL(...)) —— Node 官方的跨平台转换。
全仓已无同类残留。本地 195 单测 / 29 e2e 复跑全绿。
This commit is contained in:
1 parent
af1cd39fdf
commit
25f889c6d8
1 file changed
+2
-1
@@ -21,8 +21,9 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ROOT = new URL('../../', import.meta.url).pathname;
|
||||
const ROOT = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const PS_DIR = join(ROOT, 'scripts');
|
||||
|
||||
/** 收集仓库里所有需要分发的 .ps1(含子目录) */
|
||||
|
||||
Reference in new issue
Block a user