Skip to content

fix(windows): make lint, typecheck, build, three test suites and the git hooks run on Windows - #1398

Merged
realcodesiman merged 6 commits into
ChatbotXIO:mainfrom
rawdaymx:fix/windows-contributor-toolchain
Oct 24, 2026
Merged

realcodesiman merged 6 commits into
ChatbotXIO:mainfrom
rawdaymx:fix/windows-contributor-toolchain

Conversation

@rawdaymx

@rawdaymx rawdaymx commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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:

Commit What it fixes Change
fix(scripts) root pnpm lint fails with 0 of 2 tasks (spawnSync drizzle-kit ENOENT) resolve drizzle-kit's declared bin entry, launch it with process.execPath, fall back to the bare command
build(builder) check-types and build die before doing any work (cmd.exe cannot parse a VAR=value prefix) tsc through node with the heap flag; dotenv -v SKIP_ENV_CHECK=true. No new dependency
test 6 cases fail in 3 suites comparing a backslash path against a / path normalise both sides to /; assertions, allowlists and patterns unchanged
chore(hooks) post-checkout and commit-msg always abort, even on valid input move the two multiline bodies verbatim into scripts/git-hooks/, invoke through sh

How it was verified

Every exit code read directly, not through a pipe. All suites run with --force, so nothing came from cache.

Before, on e4913ef2a with no local workaround in place:

  • root pnpm lint - exit 2, Tasks: 0 successful, 2 total, Failed: @chatbotx.io/database#lint
  • pnpm --filter builder check-types - exit 1, 'NODE_OPTIONS' is not recognized as an internal or external command
  • worker suite - 2 files / 5 cases failed (263 files passed)
  • builder suite - 1 file / 1 case failed (743 files passed)
  • commit-msg hook with a valid message - exit 1, -c: line 4: syntax error: unexpected end of file

After, same machine:

  • root 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-types across the workspace 59 of 59
  • worker 265 files / 3198 cases passed · builder 744 files / 5884 passed (2 skipped) · chatbotx-mcp 12 / 178 · @chatbotx.io/database 82 / 1108
  • hooks: valid message exit 0, invalid message exit 1 with the original help text and Got: <message> intact; branch gate exercised on a non-matching name (exit 1), a matching one (exit 0) and main (exit 0), in a throwaway repository so the rejection path could be seen without renaming branches here

The two env-shaped fixes were measured with the script-shell override removed in both passes, so the green is the fix and not a local workaround. The hook scripts are invoked through sh rather 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=8192 on six further check-types scripts. In the current form that multiplies the cmd.exe problem by six; the node --max-old-space-size=... tsc form in this PR is portable and puts the flag where it has to be anyway.

… 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.
@github-actions github-actions Bot added the bug Something isn't working as expected label Oct 2, 2026
@realcodesiman
realcodesiman merged commit da6aa1d into ChatbotXIO:main Oct 24, 2026
3 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows contributors cannot run pnpm lint, the builder's typecheck and build, two test suites, or the git hooks: four independent causes

2 participants