-
Notifications
You must be signed in to change notification settings - Fork 556
fix(cli): pass options to semver.valid() for loose version validation #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b4fa6e7 to
643da59
Compare
mbtools
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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`] = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be deleted. There was a test missing in #753 (see below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(' '))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the missing test after -i 1.2.3:
['-i', 'release', '1.0.0-pre'],
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done - added.
Update from 7.7.1 to 7.7.3 (already contains npm/node-semver#835)
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
mbtools
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! lgtm
|
Thanks @mldangelo for writing this and thanks @mbtools for walking it through the review process to completion. |
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