Run the tests before publishing - #10
Merged
Merged
Conversation
A prepublishOnly script makes npm publish fail rather than ship a broken build. Verified all three ways it needs to behave: it runs on publish, it aborts the publish with a non-zero exit when a test fails, and it leaves npm pack alone, since packing is not publishing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QJR2DDBimsijgYgZS3bUS8
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.
Adds a
prepublishOnlyguard sonpm publishfails rather than ships a broken build.Verified, not assumed
A guard that does not actually block is worse than none, so I checked all three behaviours it needs:
npm publish> shadowtools@4.0.0 prepublishOnly→npm test→# pass 62npm error code 1, exit 1, nothing publishednpm packThe temporary failing test was removed afterwards; the suite is back to 62 passing.
Why it is worth the one line
The package is about to go to npm for the first time. Publishing is close to irreversible — npm restricts unpublishing after 72 hours and the name stays claimed either way — so the cost of shipping a broken version is much higher than for a normal commit. CI already covers pushes and pull requests, but nothing stood between a local working copy and the registry.
Generated by Claude Code