Skip to content

fix: add prepublishOnly guard to run tests before npm publish - #3

Merged
charlietlamb merged 1 commit into
charlietlamb:masterfrom
lifrary:fix/add-prepublish-test-guard
Mar 18, 2026
Merged

charlietlamb merged 1 commit into
charlietlamb:masterfrom
lifrary:fix/add-prepublish-test-guard

Conversation

@lifrary

@lifrary lifrary commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Currently bump and patch scripts execute npm publish directly without any pre-publish validation:

"bump": "npm version prerelease --preid=beta --workspaces=false && npm publish --tag beta",
"patch": "npm version patch --workspaces=false && npm publish --tag latest"

If tests happen to be failing at the time of publish, a broken package can still be released to npm. This is easy to miss especially when iterating quickly during beta.

Solution

Add a prepublishOnly lifecycle hook that runs bun test before every npm publish:

"prepublishOnly": "bun test"

prepublishOnly is an npm lifecycle script that runs automatically before npm publish and before npm pack. If tests fail, the publish is aborted — no manual step needed.

What changes

  • packages/ol/package.json: Added "prepublishOnly": "bun test" to scripts

How it works

npm publish
  └─ prepublishOnly (bun test)
       ├─ tests pass → publish proceeds ✅
       └─ tests fail → publish aborted ❌

Both bump and patch scripts will now be guarded automatically since they both call npm publish internally.

Testing

Verified locally:

  • npm publish --dry-run triggers prepublishOnly and runs bun test as expected
  • If a test is intentionally broken, publish is correctly aborted

Summary by cubic

Add prepublishOnly to run bun test before every npm publish, so publishes abort if tests fail. This guards both bump and patch flows in packages/ol to prevent broken releases.

Written for commit c2bda75. Summary will update on new commits.

Currently the bump and patch scripts run npm publish directly
without any validation. This means a broken build can be
published to npm if tests are not run manually beforehand.

Adding prepublishOnly lifecycle hook ensures bun test runs
automatically before every npm publish, preventing broken
releases from reaching users.

Co-Authored-By: seungwoolee <[email protected]>
@vercel

vercel Bot commented Mar 18, 2026

Copy link
Copy Markdown

@lifrary is attempting to deploy a commit to the charlietlamb's projects Team on Vercel.

A member of the Team first needs to authorize it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@charlietlamb

Copy link
Copy Markdown
Owner

LGTM - Thanks for the contribution!

@charlietlamb
charlietlamb merged commit 876961b into charlietlamb:master Mar 18, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants