summaryrefslogtreecommitdiff
path: root/cli/npm/tarball.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-01-31 21:27:40 -0500
committerGitHub <noreply@github.com>2023-01-31 21:27:40 -0500
commit600fff79cdf5d52154344a0e3a8a523e1e21c3c1 (patch)
tree89e10e4a5fe1c6a67e8955c6710ff16aa25ef853 /cli/npm/tarball.rs
parente85ca8be0dafdab28e6283aed64c8ee0eb3a338d (diff)
refactor(semver): generalize semver related structs (#17605)
- Generalizes the npm version code (ex. `NpmVersion` -> `Version`, `NpmVersionReq` -> `VersionReq`). This is a slow refactor towards extracting out this code for deno specifiers and better usage in deno_graph. - Removes `SpecifierVersionReq`. Consolidates `NpmVersionReq` and `SpecifierVersionReq` to just `VersionReq` - Removes `NpmVersionMatcher`. This now just looks at `VersionReq`. - Paves the way to allow us to create `NpmPackageReference`'s from a package.json's dependencies/dev dependencies (`VersionReq::parse_from_npm`).
Diffstat (limited to 'cli/npm/tarball.rs')
-rw-r--r--cli/npm/tarball.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/npm/tarball.rs b/cli/npm/tarball.rs
index 758ac3ded..3abf4f12f 100644
--- a/cli/npm/tarball.rs
+++ b/cli/npm/tarball.rs
@@ -13,10 +13,10 @@ use tar::EntryType;
use super::cache::with_folder_sync_lock;
use super::registry::NpmPackageVersionDistInfo;
-use super::semver::NpmVersion;
+use crate::semver::Version;
pub fn verify_and_extract_tarball(
- package: (&str, &NpmVersion),
+ package: (&str, &Version),
data: &[u8],
dist_info: &NpmPackageVersionDistInfo,
output_folder: &Path,
@@ -29,7 +29,7 @@ pub fn verify_and_extract_tarball(
}
fn verify_tarball_integrity(
- package: (&str, &NpmVersion),
+ package: (&str, &Version),
data: &[u8],
npm_integrity: &str,
) -> Result<(), AnyError> {
@@ -120,12 +120,11 @@ fn extract_tarball(data: &[u8], output_folder: &Path) -> Result<(), AnyError> {
#[cfg(test)]
mod test {
use super::*;
- use crate::npm::semver::NpmVersion;
#[test]
pub fn test_verify_tarball() {
let package_name = "package".to_string();
- let package_version = NpmVersion::parse("1.0.0").unwrap();
+ let package_version = Version::parse_from_npm("1.0.0").unwrap();
let package = (package_name.as_str(), &package_version);
let actual_checksum =
"z4phnx7vul3xvchq1m2ab9yg5aulvxxcg/spidns6c5h0ne8xyxysp+dgnkhfuwvy7kxvudbeoglodj6+sfapg==";