Skip to content

fix(githooks): guard the prepare hook installer so npm publish/pack can't crash - #254

Merged
Shinrai merged 1 commit into
nextfrom
fix/githooks-prepare-publish-crash
Sep 2, 2026
Merged

Shinrai merged 1 commit into
nextfrom
fix/githooks-prepare-publish-crash

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

  • fix(githooks): guard the prepare hook installer so npm publish/pack can't crash (6044839)

📦 Dependencies

No dependency updates

🔧 Other Changes

No other changes

👥 Contributors

… 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
@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch type: config Changes to repository or project configuration files type: documentation Relates to docs, README updates, guides, or inline code comments labels Sep 2, 2026
@Shinrai

Shinrai commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Resolves #250 — closed when this ships to the default branch.

@Shinrai
Shinrai merged commit d8cdf91 into next Sep 2, 2026
16 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/githooks-prepare-publish-crash branch September 2, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

! fix → next v4 flow: fix contributor PR targeting the next integration branch type: config Changes to repository or project configuration files type: documentation Relates to docs, README updates, guides, or inline code comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant