fix(cli): pass options to semver.valid() for loose version validation#835
Merged
fix(cli): pass options to semver.valid() for loose version validation#835
Conversation
b4fa6e7 to
643da59
Compare
mbtools
reviewed
Jan 14, 2026
Contributor
mbtools
left a comment
There was a problem hiding this comment.
LGTM. Thanks for fixing the bug. Please just add the missing test.
| } | ||
| ` | ||
|
|
||
| exports[`test/bin/semver.js TAP inc tests > -i release 1.0.0-pre`] = ` |
Contributor
There was a problem hiding this comment.
This should not be deleted. There was a test missing in #753 (see below).
Contributor
Author
There was a problem hiding this comment.
Good catch! Added the missing test ['-i', 'release', '1.0.0-pre'] which restores this snapshot.
| ['-i', 'premajor', '1.0.0', '--preid=beta', '-n', '1'], | ||
| ['-i', 'premajor', '1.0.0', '--preid=beta', '-n', 'false'], | ||
| ['-i', '1.2.3'], | ||
| ].map(args => t.resolveMatchSnapshot(run(args), args.join(' '))))) |
Contributor
There was a problem hiding this comment.
Please add the missing test after -i 1.2.3:
['-i', 'release', '1.0.0-pre'],
mbtools
added a commit
to abapPM/ABAP-SemVer
that referenced
this pull request
Jan 14, 2026
Update from 7.7.1 to 7.7.3 (already contains npm/node-semver#835)
Merged
The `--loose` flag was not being applied when validating input versions. The `options` object was already computed and passed to `coerce()` and `satisfies()`, but the `filter()` call using `semver.valid(v)` was missing the options parameter. This meant that loose versions like `1.2.3beta` would fail validation even when `-l` was specified, despite the documentation stating that `-l --loose` will "Interpret versions and ranges loosely".
643da59 to
8a90577
Compare
Member
|
Thanks @mldangelo for writing this and thanks @mbtools for walking it through the review process to completion. |
wraithgar
approved these changes
Jan 15, 2026
Merged
Member
wraithgar
pushed a commit
that referenced
this pull request
Feb 5, 2026
🤖 I have created a release *beep* *boop* --- ## [7.7.4](v7.7.3...v7.7.4) (2026-01-16) ### Bug Fixes * [`a29faa5`](a29faa5) [#835](#835) cli: pass options to semver.valid() for loose version validation (#835) (@mldangelo) ### Documentation * [`1d28d5e`](1d28d5e) [#836](#836) fix typos and update -n CLI option documentation (#836) (@mldangelo) ### Dependencies * [`120968b`](120968b) [#840](#840) `@npmcli/template-oss@4.29.0` (#840) ### Chores * [`44d7130`](44d7130) [#824](#824) bump @npmcli/eslint-config from 5.1.0 to 6.0.0 (#824) (@dependabot[bot]) * [`7073576`](7073576) [#820](#820) reorder parameters in invalid-versions.js test (#820) (@reggi) * [`5816d4c`](5816d4c) [#829](#829) bump @npmcli/template-oss from 4.28.0 to 4.28.1 (#829) (@dependabot[bot], @npm-cli-bot) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This comment was marked as spam.
This comment was marked as spam.
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.
Summary
The
--looseflag was not being applied when validating input versions.Problem
The
optionsobject (containingloose: true) was already being passed tocoerce()andsatisfies(), but thefilter()validation step was callingsemver.valid(v)without it.Fix
Test plan
1.2.3beta -l