Repository navigation
fix(githooks): guard the prepare hook installer so npm publish/pack can't crash - #254
Merged
Merged
Conversation
… can't crash
The bare `"prepare": "node .githooks/install.mjs"` runs on `npm pack` and
`npm publish` too, against the packed tree — where `.githooks/` is excluded from
`files`, so node can't resolve the module and aborts the publish before
install.mjs's own guards run. Switch to the guarded form
`node -e "import('./.githooks/install.mjs').catch(()=>{})"`, which no-ops
silently when the file is absent (pack/publish) and still installs the hook on a
normal dev `npm install`.
Applied to all four carriers of the bare form, incl. this repo's own live
wiring, so .github itself is no longer latently broken:
- package.json (this repo's own prepare script)
- .githooks/install.mjs + examples/git-hooks/install.mjs (doc comment; the
example is what consumers copy) — with a note on why the wrapper is required
- docs/conventions/lint-format-precommit.md (snippet + prose)
Verified: guarded form exits 0 in a packed tree (no .githooks) and still installs
the hook in a dev checkout; the bare form exits 1 in the packed tree.
Fixes #250
Contributor
|
Resolves #250 — closed when this ships to the default branch. |
Shinrai
approved these changes
Sep 2, 2026
This was referenced Sep 2, 2026
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.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
preparehook installer so npm publish/pack can't crash (6044839)📦 Dependencies
No dependency updates
🔧 Other Changes
No other changes
👥 Contributors