Repository navigation
fix(windows): make lint, typecheck, build, three test suites and the git hooks run on Windows - #1398
Merged
realcodesiman merged 6 commits intoOct 24, 2026
Conversation
… on Windows
spawnSync("drizzle-kit", …) cannot execute the .CMD shim pnpm installs on
Windows without a shell, so the probe fails with ENOENT and packages/database's
lint script exits 2 — which takes the whole `pnpm lint` down for any Windows
contributor. Resolve the package's declared bin entry and launch it with
process.execPath instead, falling back to the bare command when the entry
cannot be found.
…s run on Windows On Windows lefthook runs a job body as sh.exe -c "<body>". The post-checkout and commit-msg bodies contain double quotes of their own (grep -qE "$PATTERN"), which close that argument early: sh receives an `if` with no `fi` and answers `syntax error: unexpected end of file`, so both hooks fail even when the branch name and the commit message are valid. The two single-line jobs in the same file are unaffected because they carry no double quotes. The bodies move verbatim into scripts/git-hooks/ and are invoked through `sh`, so neither the quoting nor the executable bit (which Windows does not carry) is in the way. Same patterns, same messages, same exit codes.
pnpm runs package scripts through cmd.exe on Windows, which does not understand the POSIX `VAR=value command` prefix: both scripts die immediately with `'NODE_OPTIONS' is not recognized as an internal or external command`, so neither `pnpm --filter builder check-types` nor the builder's build can run there. These are the only two scripts in the monorepo using that form. check-types launches tsc through node, which is also where the heap flag has to go; build moves SKIP_ENV_CHECK into `dotenv -v`, already available in the dotenv-cli version this package depends on. No new dependency.
…indows Three suites build an expectation with node's `join`/`relative` (which uses "\\" on Windows) and compare it against a value that is always "/"-separated: the shell script's own output in docker-entrypoint, and a hand-written allowlist in the other two. On Windows the two sides never match, so 6 cases fail for a reason that has nothing to do with what they assert. Normalise both sides to "/" before comparing. The assertions, the allowlists and the patterns are unchanged.
1 task
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
…git hooks run on Windows (#1398)
* fix(scripts): launch drizzle-kit through node so the drift check runs on Windows
spawnSync("drizzle-kit", …) cannot execute the .CMD shim pnpm installs on
Windows without a shell, so the probe fails with ENOENT and packages/database's
lint script exits 2 — which takes the whole `pnpm lint` down for any Windows
contributor. Resolve the package's declared bin entry and launch it with
process.execPath instead, falling back to the bare command when the entry
cannot be found.
* chore(hooks): move the multiline hook bodies into scripts so the hooks run on Windows
On Windows lefthook runs a job body as sh.exe -c "<body>". The post-checkout
and commit-msg bodies contain double quotes of their own (grep -qE "$PATTERN"),
which close that argument early: sh receives an `if` with no `fi` and answers
`syntax error: unexpected end of file`, so both hooks fail even when the branch
name and the commit message are valid. The two single-line jobs in the same
file are unaffected because they carry no double quotes.
The bodies move verbatim into scripts/git-hooks/ and are invoked through `sh`,
so neither the quoting nor the executable bit (which Windows does not carry)
is in the way. Same patterns, same messages, same exit codes.
* build(builder): set the two script env vars in a form cmd.exe can parse
pnpm runs package scripts through cmd.exe on Windows, which does not understand
the POSIX `VAR=value command` prefix: both scripts die immediately with
`'NODE_OPTIONS' is not recognized as an internal or external command`, so
neither `pnpm --filter builder check-types` nor the builder's build can run
there. These are the only two scripts in the monorepo using that form.
check-types launches tsc through node, which is also where the heap flag has to
go; build moves SKIP_ENV_CHECK into `dotenv -v`, already available in the
dotenv-cli version this package depends on. No new dependency.
* test: compare paths with a single separator so three suites pass on Windows
Three suites build an expectation with node's `join`/`relative` (which uses
"\\" on Windows) and compare it against a value that is always "/"-separated:
the shell script's own output in docker-entrypoint, and a hand-written allowlist
in the other two. On Windows the two sides never match, so 6 cases fail for a
reason that has nothing to do with what they assert.
Normalise both sides to "/" before comparing. The assertions, the allowlists
and the patterns are unchanged.
* refactor(test): clarify path normalization
* chore(hooks): mark hook scripts executable
---------
Co-authored-by: Real Codesiman <[email protected]>
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.
Fixes #1397
Four independent reasons a Windows contributor cannot use this repository today, one commit each so you can take or drop them separately. Details, mechanisms and the full before/after numbers are in the issue; the short version:
fix(scripts)pnpm lintfails with 0 of 2 tasks (spawnSync drizzle-kit ENOENT)drizzle-kit's declared bin entry, launch it withprocess.execPath, fall back to the bare commandbuild(builder)check-typesandbuilddie before doing any work (cmd.execannot parse aVAR=valueprefix)tscthroughnodewith the heap flag;dotenv -v SKIP_ENV_CHECK=true. No new dependencytest/path/; assertions, allowlists and patterns unchangedchore(hooks)post-checkoutandcommit-msgalways abort, even on valid inputscripts/git-hooks/, invoke throughshHow it was verified
Every exit code read directly, not through a pipe. All suites run with
--force, so nothing came from cache.Before, on
e4913ef2awith no local workaround in place:pnpm lint- exit 2,Tasks: 0 successful, 2 total,Failed: @chatbotx.io/database#lintpnpm --filter builder check-types- exit 1,'NODE_OPTIONS' is not recognized as an internal or external commandworkersuite - 2 files / 5 cases failed (263 files passed)buildersuite - 1 file / 1 case failed (743 files passed)commit-msghook with a valid message - exit 1,-c: line 4: syntax error: unexpected end of fileAfter, same machine:
pnpm lint- exit 0,Tasks: 2 successful, 2 total, and the drift check actually runs:Schema is in sync with the migration snapshot chain.pnpm --filter builder check-types- exit 0, full typecheck completes;check-typesacross the workspace 59 of 59worker265 files / 3198 cases passed ·builder744 files / 5884 passed (2 skipped) ·chatbotx-mcp12 / 178 ·@chatbotx.io/database82 / 1108Got: <message>intact; branch gate exercised on a non-matching name (exit 1), a matching one (exit 0) andmain(exit 0), in a throwaway repository so the rejection path could be seen without renaming branches hereThe two env-shaped fixes were measured with the
script-shelloverride removed in both passes, so the green is the fix and not a local workaround. The hook scripts are invoked throughshrather than relying on the executable bit, which Windows checkouts do not carry.Deliberately not included
Two suites have gone over their 5s and 30s budgets in loaded full-suite runs on this machine, but they passed on today's baseline, so there is no reproducible failure to justify changing them and no commit here does.
Note on #1169
#1169 asks for
NODE_OPTIONS=--max-old-space-size=8192on six furthercheck-typesscripts. In the current form that multiplies thecmd.exeproblem by six; thenode --max-old-space-size=... tscform in this PR is portable and puts the flag where it has to be anyway.