fix(scripts): make test scripts cross-platform with cross-env#1079
Conversation
The `test`, `test:watch`, and `test:coverage` scripts used a bare `NODE_OPTIONS=--max-old-space-size=8192 vitest ...` env-var prefix. That syntax only works in POSIX shells. On Windows, npm runs scripts through cmd.exe, which treats `NODE_OPTIONS=...` as a command and fails with "'NODE_OPTIONS' is not recognized as an internal or external command". Because the pre-push hook runs `npm run validate:push` -> `npm run test`, this broke `git push` for every Windows contributor, forcing a `--no-verify` bypass that skips the entire validation gate (prettier, type checks, ESLint, tests). Wrap the three scripts with `cross-env` (added as a devDependency) so the env var is set portably across Windows, macOS, and Linux. Verified under cmd.exe: the bare form fails with exit 1, the cross-env form propagates NODE_OPTIONS correctly and exits 0.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR updates npm test scripts to use ChangesTest Script Cross-platform Configuration
🎯 1 (Trivial) | ⏱️ ~2 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR wraps the three main test scripts (
Confidence Score: 5/5Safe to merge - the change is a minimal, correct addition of cross-env that makes test scripts functional on Windows without touching any application logic. The change adds a well-established utility (cross-env 7.0.3) as a dev dependency and applies it only to the three test scripts that previously failed on Windows. The lockfile integrity hash matches the published package, the sub-dependency (cross-spawn) is already present at a compatible version, and no production code or runtime behavior is affected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[npm run test / test:watch / test:coverage] --> B[cross-env]
B --> C{Platform?}
C -->|Windows| D[Sets NODE_OPTIONS via SET command]
C -->|macOS / Linux| E[Sets NODE_OPTIONS via export]
D --> F[vitest run / vitest]
E --> F
F --> G[8192 MB heap limit applied]
Reviews (1): Last reviewed commit: "fix(scripts): make test scripts cross-pl..." | Re-trigger Greptile |
@-
Summary by CodeRabbit