Repository navigation
cli: name the accepted range in Invalid port and fold the port parsers' checks - #1075
Merged
Merged
Conversation
…ers' checks Follow-up polish to #1062 from the review of #1050: - Fold the digits-only check and the range check into one condition in both parsers. After `/^\d+$/`, Number() can only return a non-negative integer or Infinity, so the separate `Number.isInteger` guard was redundant. - An invalid `--port` now says what is accepted: `1 to 65535` for b4 dev and b4 inspect, `0 to 65535` for b4 start. - Fix the stale "dev.ts's parsePort" comment in start.ts; the shared parser lives in lib/dev/parse-port.ts. - Update the message assertions and cover `parsePort("0")`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
This branch was successfully deployed
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.
Follow-up polish to #1062, from the maintainer review of the software factory's #1050. No change to which values are accepted; only the error text and the shape of the checks change.
Changes
One condition per parser.
packages/cli/src/lib/dev/parse-port.tsandpackages/cli/src/commands/start.tseach folded the digits-only test and the range test into a singleif. After/^\d+$/,Number()can only yield a non-negative integer orInfinity(which fails> 65535), so the separateNumber.isIntegerguard was redundant.The error names the accepted range.
b4 dev/b4 inspect:Invalid port: 70000 (expected an integer from 1 to 65535)b4 start:Invalid port: 70000 (expected an integer from 0 to 65535), since it accepts0for a kernel-assigned port.The exit code stays
2.Stale comment fixed.
start.tsreferred to "dev.ts's parsePort"; the shared parser lives inlib/dev/parse-port.tsand servesb4 devandb4 inspect.Tests.
port-parse.test.tsandstart-command.test.tsassert the new messages, andparsePort("0")is now covered.Changeset.
.changeset/port-parser-range-message.md,@b4run/clipatch.Out of scope:
resolveServePortinserve-runtime.ts(thePORTenv var, #1066) silently falls back to 8000 instead of throwing. That is a deliberate, separate contract.Verification (local, at the repo root)
pnpm lint,pnpm build, andpnpm --filter @b4run/cli typecheck: passpnpm --filter @b4run/cli test: 2879 passed, 4 skipped, 0 failednode scripts/check-changesets.mjs: passed🤖 Generated with Claude Code