Repository navigation
fix(ci): pre-push 的 pnpm CLI 候选增加 JS 形态校验,修复 mise 独立版 pnpm 下 Windows 推送必挂 - #57
Open
yachen4ever wants to merge 1 commit into
Open
yachen4ever wants to merge 1 commit into
yachen4ever wants to merge 1 commit into
Conversation
run-affected-unit-tests.mjs 的 resolvePnpmCliPath 此前只要 npm_execpath 路径含 \pnpm\ 就当作 JS CLI 直接交给 process.execPath 执行;mise 独立版 pnpm 的 npm_execpath 指向原生 pnpm.exe(MZ 头二进制),node 加载即 SyntaxError,所有 涉及测试文件变更的 Windows 推送都被 pre-push 钩子拦死。 抽出 scripts/pnpm-cli-resolver.mjs(原脚本顶层即执行 main(),无法直接导入测试), 候选需通过扩展名校验(.cjs/.mjs/.js)才走 node 执行,否则回落 PATH 搜索与 shell 兜底。行为对 corepack/npm 形态的 pnpm 无变化。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #54
改动(3 文件,+55/−27)
scripts/pnpm-cli-resolver.mjs:从run-affected-unit-tests.mjs抽出resolvePnpmCliPath(原脚本顶层即执行main(),无法被测试导入),并新增isJsEntryPath形态校验——候选扩展名必须是.cjs/.mjs/.js才交给process.execPath当 JS 入口,否则回落到既有的 PATH 搜索与shell: true兜底。run-affected-unit-tests.mjs改为从新模块导入,删除本地实现与不再使用的delimiter导入,其余行为不变。scripts/pnpm-cli-resolver.test.mjs(node --test,与 scripts 下其他测试同惯例)。根因
resolvePnpmCliPath原先只检查npm_execpath路径含\pnpm\就当作 JS CLI:mise 独立版 pnpm 恰好把npm_execpath指向<mise>/installs/pnpm/10.33.2/pnpm.exe(原生二进制),node 加载即SyntaxError——凡 push 涉及测试文件变更(含「已删除测试文件触发全量回退」路径),Windows 上的 pre-push 钩子必挂。对 corepack/npm 形态(npm_execpath 本就是 .cjs)零行为变化。验证
node --test scripts/pnpm-cli-resolver.test.mjs:4/4 通过(含 mise pnpm.exe 形态被拒、PATH 候选回退两条关键路径)。ZCODE_AFFECTED_TEST_BASE=<HEAD> node scripts/run-affected-unit-tests.mjs冒烟:模块接线正常、退出码 0。pnpm lint:0 错误。