fix: only run husky in a git checkout so npm consumers don't break#3211
Conversation
postinstall ran husky unconditionally. npm executes a dependency's postinstall for every consumer, but husky is a devDependency and isn't installed in a consumer's tree, so `npm install stream-chat-react` failed with `code 127 Β· husky: command not found`. Yarn Berry runs the root workspace's postinstall on `yarn install` but not its prepare, so husky must stay in postinstall; the fix is to stop running it for consumers. postinstall now invokes a dev-only scripts/install-husky.mjs only when present, and that file is intentionally not in package.json#files, so consumers never receive it and the guard short-circuits to a no-op. The invocation runs via node (not a shell `|| true`) for Windows compatibility, and genuine husky setup errors surface instead of being swallowed. Ports GetStream/stream-chat-js#1764.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (2)
π WalkthroughWalkthroughThe PR updates the post-install setup to conditionally initialize Husky Git hooks. The ChangesConditional Husky Installation
Estimated code review effortπ― 1 (Trivial) | β±οΈ ~3 minutes Poem
π₯ Pre-merge checks | β 5β Passed checks (5 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ Generate docstrings
π§ͺ 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 |
|
Size Change: 0 B Total Size: 656 kB βΉοΈ View Unchanged
|
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3211 +/- ##
=======================================
Coverage 83.92% 83.92%
=======================================
Files 439 439
Lines 13222 13222
Branches 4293 4293
=======================================
Hits 11097 11097
Misses 2125 2125 β View full report in Codecov by Harness. π New features to boost your workflow:
|
## [14.4.1](v14.4.0...v14.4.1) (2026-06-05) ### Bug Fixes * only run husky in a git checkout so npm consumers don't break ([#3211](#3211)) ([640bf4b](640bf4b))
|
π This PR is included in version 14.4.1 π The release is available on: Your semantic-release bot π¦π |
π― Goal
postinstallranhuskyunconditionally. npm executes a dependency'spostinstallfor every consumer, buthuskyis adevDependencyand isn't installed in a consumer's tree, sonpm install stream-chat-reactfailed:This ports the same fix already merged for the JS SDK in GetStream/stream-chat-js#1764 β
stream-chat-reacthad the identical"postinstall": "husky".π Implementation details
Why husky has to stay in
postinstall: Yarn Berry (this repo's package manager) runs the root workspace'spostinstallonyarn installbut not itsprepare. Moving husky topreparewould silently stop installing contributors' git hooks. husky must stay inpostinstall; the fix is to stop running it for consumers.postinstallnow invokes a dev-onlyscripts/install-husky.mjsonly when it is present β and that file is intentionally not inpackage.json#files(which publishes onlydist,package.json,README.md,AI.md), so consumers never receive it and the guard short-circuits to a no-op.node(not a shell|| true) so it's cross-platform β npm runs consumer postinstalls throughcmd.exeon Windows, where||/truearen't valid.scripts/install-husky.mjsruns husky only inside a git checkout, and lets genuine husky setup errors surface (not swallowed) so contributors learn if hook installation actually fails.Verified locally:
scripts/install-husky.mjs).git+ script present)core.hooksPath=.husky/_Β· hooks installed Β· exit 0yarn prettierandyarn eslintclean on both changed files.π¨ UI Changes
None β build/install tooling only.
Summary by CodeRabbit