scripts: path comparisons break on Windows (check-greys fails the pre-push hook, upgrade-opentui skips nothing)
Description
Two repository scripts compare paths from Bun.Glob against strings written with /. The glob returns the platform separator, so on Windows neither comparison works. The repo already normalises for this in one place (script/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts:31), so the convention exists and these two missed it.
script/check-greys.ts — fails the pre-push hook on Windows
EXCEPTIONS are written with / (/style\/token\/color\.css$/, /component\/video-editor\//, …) and matched with EXCEPTIONS.find(([re]) => re.test(file)) (:74). On Windows every scanned path is services\site\src\…, so no exception matches and the checker reports greys from the files the list exists to excuse — legacy tokens, the video editor, the font film, print.
Because bun run check is the pre-push hook, every Windows contributor is blocked until they push with --no-verify, which weakens the hook for everyone.
$ bun script/check-greys.ts
services\site\src\style\token\color.css:7 #f5f5f7 not on the scale
…
172 greys off the shared scale (script/check-greys.ts). # exit 1
script/upgrade-opentui.ts — the skip list silently does nothing
const skip = new Set([".git", ".opencode", ".turbo", "dist", "node_modules"])
…
(file) => !file.split("/").some((part) => skip.has(part))
On Windows file.split("/") yields one part (node_modules\foo\package.json), so skip never matches and the script would rewrite the version field of every package.json under node_modules and dist.
Environment
- opencode
devatb0cda20 - Windows 10 22H2, Bun 1.4.5, PowerShell 5.1
Steps to reproduce
- Clone on Windows without Developer Mode.
bun script/check-greys.ts→ 172 problems, exit 1. On Linux the same command exits 0.- Read
script/upgrade-opentui.ts:41-43: the filter keepsnode_modulesanddistentries on Windows.
Expected behavior
Both scripts match on a separator-normalised path, so the same files are exempted and the same directories are skipped on every platform.
Additional context
Fixes are ready on two branches (check-greys one expression; upgrade-opentui one expression). Verified on Windows: bun script/check-greys.ts exit 1 → 0, bun run lint exit 0, and bun run check 36/36 tasks exit 0 once the checkout's 29 symlinks are materialised (they land as text files without Developer Mode, which is a separate, environment-only obstacle).
Not observed; this looks likely from reading the code.
Thanks for the precise write-up. I couldn't run this on Windows, so I confirmed it by reading the code. Both comparisons are still unchanged on the latest dev (fb56d1c):
script/check-greys.tstests theEXCEPTIONSregexes, which are written with/, directly against the pathsBun.Globreturns. The script runs as part ofbun run lint, whichbun run checkand the pre-push hook run, so with Windows backslash paths none of the exceptions match.script/upgrade-opentui.tsfilters withfile.split("/"), so on Windows thenode_modules,dist,.git,.opencodeand.turboentries are never skipped.
The check-greys half is already tracked in #63615, with a fix in the open PR #63619. #64740 was a duplicate of it. I found no issue or PR for the upgrade-opentui half, so this issue covers it.
I can take the remaining script/upgrade-opentui.ts part of #66192. PR #63619 covers only the check-greys part; I would keep this change scoped to Windows-safe path filtering in the upgrade script and a focused regression test. Could a maintainer assign the issue to me? I will wait for confirmation before changing code, following CONTRIBUTING.md.
Thanks — and good catch on #63615 / #63619; I had not found them. That changes what this issue is: the check-greys half is already covered by the open PR #63619, so the part that is genuinely new here is upgrade-opentui.
@deosiree — the upgrade-opentui half is yours. I've deleted my branch (script-path-separators) so there is nothing to conflict with, and I'd rather hand over the work than race you the way #66165 got closed.
So you don't have to re-derive it, this is the one-line change that fixes it:
const files = (await Array.fromAsync(new Bun.Glob("**/package.json").scan({ cwd: root }))).filter(
- (file) => !file.split("/").some((part) => skip.has(part)),
+ // The glob returns the platform separator; splitting on "/" alone would keep every skipped directory on Windows.
+ (file) => !file.replaceAll("\\", "/").split("/").some((part) => skip.has(part)),
)
Non-obvious things I checked while doing it:
script/pack.ts:18looks similar but is safe — it usesfile.includes("node_modules"), which is separator-agnostic.- The repo already normalises this way for a path check:
script/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts:31does.replaceAll("\\", "/")oncontext.filename. That is the convention to match. - A regression test can exercise the filter expression with Windows-style inputs without spawning the script:
node_modules\foo\package.jsonandpackages\app\dist\package.jsonmust be excluded,packages\app\package.jsonkept, and POSIX paths unchanged. I ran exactly that table; all six cases behaved.
One note for whoever writes the test: the root script/ folder has no test runner in CI (the root test script refuses, and bun test is guarded), so a test there may never run. A unit test is easiest if the filter is extracted, or the desktop package's script/ tests are the precedent to copy.
I'm not touching the check-greys half; #63619 owns it.