Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

refactor: replace @epic-web/invariant with simple code#267

Merged
kentcdodds merged 1 commit into
kentcdodds:mainfrom
hyperz111:invariant
Nov 16, 2025
Merged

refactor: replace @epic-web/invariant with simple code#267
kentcdodds merged 1 commit into
kentcdodds:mainfrom
hyperz111:invariant

Conversation

@hyperz111
Copy link
Copy Markdown
Contributor

@hyperz111 hyperz111 commented Nov 14, 2025

What:

Replace @epic-web/invariant with simple code. (This is like #266)

Why:

We only use one function (invariant) from @epic-web/invariant which is can be reached with this simple code:

if (!condition) {
    throw new Error(/* ... */)
}

By doing that, cross-env now only use 1 dependency (cross-spawn).

How:

Replace @epic-web/invariant with simple code like on top.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 14, 2025

Walkthrough

The changes remove the @epic-web/invariant dependency from package.json and replace its single usage in src/index.ts with an inline error throw statement for command validation.

Changes

Cohort / File(s) Change Summary
Dependency Removal
package.json
Removed @epic-web/invariant from the dependencies section
Runtime Validation Refactor
src/index.ts
Replaced invariant() utility call with inline if (!parsedCommand) throw new Error('Command is required') statement

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Straightforward dependency removal with corresponding inline replacement
  • Single validation point changed with identical behavior
  • No alterations to exported APIs or function signatures

Poem

🐰 A dependency falls away,
Invariant thought now simplified,
The throw speaks clear as day—
Direct and verified.
Less magic, more true. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: replace @epic-web/invariant with simple code' accurately and specifically describes the main change: replacing a dependency with inlined code.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hyperz111 hyperz111 changed the title refactor: replace invariant with simple code refactor: replace @epic-web/invariant with simple code Nov 14, 2025
@hyperz111
Copy link
Copy Markdown
Contributor Author

@kentcdodds, what about this?

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 16, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.71%. Comparing base (2ff1d88) to head (ec26983).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/index.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #267      +/-   ##
===========================================
- Coverage   100.00%   98.71%   -1.29%     
===========================================
  Files            4        4              
  Lines          155      156       +1     
  Branches        52       53       +1     
===========================================
- Hits           155      154       -1     
- Misses           0        2       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kentcdodds kentcdodds merged commit 9951937 into kentcdodds:main Nov 16, 2025
7 of 10 checks passed
@hyperz111 hyperz111 deleted the invariant branch November 16, 2025 22:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants