1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(npm): correct exact matching of pre-release versions (#15745)

This commit is contained in:
David Sherret 2022-09-02 11:21:40 -04:00 committed by GitHub
parent 387300aed0
commit 03e6727a04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View file

@ -514,7 +514,7 @@ fn get_resolved_package_version_and_info(
None => bail!( None => bail!(
concat!( concat!(
"Could not find npm package '{}' matching {}{}. ", "Could not find npm package '{}' matching {}{}. ",
"Try retreiving the latest npm package information by running with --reload", "Try retrieving the latest npm package information by running with --reload",
), ),
pkg_name, pkg_name,
version_matcher.version_text(), version_matcher.version_text(),

View file

@ -313,9 +313,7 @@ fn simple(input: &str) -> ParseResult<VersionRange> {
} }
} }
}), }),
map(partial, |partial| { map(partial, |partial| partial.as_equal_range()),
partial.as_greater_range(VersionBoundKind::Inclusive)
}),
)(input) )(input)
} }
@ -842,6 +840,8 @@ mod tests {
("1.0.0 - x", "1.9.7"), ("1.0.0 - x", "1.9.7"),
("1.x - x", "1.9.7"), ("1.x - x", "1.9.7"),
("<=7.x", "7.9.9"), ("<=7.x", "7.9.9"),
// additional tests
("1.0.0-alpha.13", "1.0.0-alpha.13"),
]; ];
for (req_text, version_text) in fixtures { for (req_text, version_text) in fixtures {
let req = NpmVersionReq::parse(req_text).unwrap(); let req = NpmVersionReq::parse(req_text).unwrap();

View file

@ -6,7 +6,6 @@ use monch::*;
use super::errors::with_failure_handling; use super::errors::with_failure_handling;
use super::range::Partial; use super::range::Partial;
use super::range::VersionBoundKind;
use super::range::VersionRange; use super::range::VersionRange;
use super::range::XRange; use super::range::XRange;
use super::NpmVersion; use super::NpmVersion;
@ -57,9 +56,7 @@ fn version_range(input: &str) -> ParseResult<VersionRange> {
map(preceded(ch('^'), partial), |partial| { map(preceded(ch('^'), partial), |partial| {
partial.as_caret_version_range() partial.as_caret_version_range()
}), }),
map(partial, |partial| { map(partial, |partial| partial.as_equal_range()),
partial.as_greater_range(VersionBoundKind::Inclusive)
}),
)(input) )(input)
} }
@ -186,6 +183,10 @@ mod tests {
assert!(tester.matches("1.0.1")); assert!(tester.matches("1.0.1"));
assert!(!tester.matches("1.0.2")); assert!(!tester.matches("1.0.2"));
assert!(!tester.matches("1.1.1")); assert!(!tester.matches("1.1.1"));
// pre-release
let tester = VersionReqTester::new("1.0.0-alpha.13");
assert!(tester.matches("1.0.0-alpha.13"));
} }
#[test] #[test]

View file

@ -1,2 +1,2 @@
Download http://localhost:4545/npm/registry/mkdirp Download http://localhost:4545/npm/registry/mkdirp
error: Could not find npm package 'mkdirp' matching 0.5.125. Try retreiving the latest npm package information by running with --reload error: Could not find npm package 'mkdirp' matching 0.5.125. Try retrieving the latest npm package information by running with --reload