summaryrefslogtreecommitdiff
path: root/cli/npm
diff options
context:
space:
mode:
Diffstat (limited to 'cli/npm')
-rw-r--r--cli/npm/cache.rs2
-rw-r--r--cli/npm/registry.rs16
-rw-r--r--cli/npm/resolution/mod.rs4
-rw-r--r--cli/npm/resolution/snapshot.rs2
-rw-r--r--cli/npm/resolution/specifier.rs12
-rw-r--r--cli/npm/resolvers/mod.rs5
-rw-r--r--cli/npm/semver/mod.rs18
-rw-r--r--cli/npm/semver/specifier.rs4
-rw-r--r--cli/npm/tarball.rs4
9 files changed, 26 insertions, 41 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs
index 6a6c6156c..0d07d27b2 100644
--- a/cli/npm/cache.rs
+++ b/cli/npm/cache.rs
@@ -216,7 +216,7 @@ impl ReadonlyNpmCache {
let encoded_name = mixed_case_package_name_encode(name);
// Using the encoded directory may have a collision with an actual package name
// so prefix it with an underscore since npm packages can't start with that
- dir.join(format!("_{}", encoded_name))
+ dir.join(format!("_{encoded_name}"))
} else {
// ensure backslashes are used on windows
for part in name.split('/') {
diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs
index 97397350d..9598feba1 100644
--- a/cli/npm/registry.rs
+++ b/cli/npm/registry.rs
@@ -131,8 +131,7 @@ impl NpmPackageVersionInfo {
let version_req =
NpmVersionReq::parse(&version_req).with_context(|| {
format!(
- "error parsing version requirement for dependency: {}@{}",
- bare_specifier, version_req
+ "error parsing version requirement for dependency: {bare_specifier}@{version_req}"
)
})?;
Ok(NpmDependencyEntry {
@@ -369,10 +368,7 @@ impl RealNpmRegistryApiInner {
Ok(value) => value,
Err(err) => {
if cfg!(debug_assertions) {
- panic!(
- "error loading cached npm package info for {}: {:#}",
- name, err
- );
+ panic!("error loading cached npm package info for {name}: {err:#}");
} else {
None
}
@@ -415,10 +411,7 @@ impl RealNpmRegistryApiInner {
self.save_package_info_to_file_cache_result(name, package_info)
{
if cfg!(debug_assertions) {
- panic!(
- "error saving cached npm package info for {}: {:#}",
- name, err
- );
+ panic!("error saving cached npm package info for {name}: {err:#}");
}
}
}
@@ -443,8 +436,7 @@ impl RealNpmRegistryApiInner {
return Err(custom_error(
"NotCached",
format!(
- "An npm specifier not found in cache: \"{}\", --cached-only is specified.",
- name
+ "An npm specifier not found in cache: \"{name}\", --cached-only is specified."
)
));
}
diff --git a/cli/npm/resolution/mod.rs b/cli/npm/resolution/mod.rs
index ed194bbac..407651ccb 100644
--- a/cli/npm/resolution/mod.rs
+++ b/cli/npm/resolution/mod.rs
@@ -112,7 +112,7 @@ impl NpmPackageId {
let (input, version) = parse_version(input)?;
match NpmVersion::parse(version) {
Ok(version) => Ok((input, (name.to_string(), version))),
- Err(err) => ParseError::fail(at_version_input, format!("{:#}", err)),
+ Err(err) => ParseError::fail(at_version_input, format!("{err:#}")),
}
}
@@ -173,7 +173,7 @@ impl NpmPackageId {
}
with_failure_handling(parse_id_at_level(0))(id)
- .with_context(|| format!("Invalid npm package id '{}'.", id))
+ .with_context(|| format!("Invalid npm package id '{id}'."))
}
pub fn display(&self) -> String {
diff --git a/cli/npm/resolution/snapshot.rs b/cli/npm/resolution/snapshot.rs
index ad6aee6d9..be64ea611 100644
--- a/cli/npm/resolution/snapshot.rs
+++ b/cli/npm/resolution/snapshot.rs
@@ -247,7 +247,7 @@ impl NpmResolutionSnapshot {
// collect the specifiers to version mappings
for (key, value) in &lockfile.content.npm.specifiers {
let package_req = NpmPackageReq::from_str(key)
- .with_context(|| format!("Unable to parse npm specifier: {}", key))?;
+ .with_context(|| format!("Unable to parse npm specifier: {key}"))?;
let package_id = NpmPackageId::from_serialized(value)?;
package_reqs.insert(package_req, package_id.clone());
verify_ids.insert(package_id.clone());
diff --git a/cli/npm/resolution/specifier.rs b/cli/npm/resolution/specifier.rs
index 6667c60dd..0aa693472 100644
--- a/cli/npm/resolution/specifier.rs
+++ b/cli/npm/resolution/specifier.rs
@@ -47,7 +47,7 @@ impl NpmPackageReference {
let parts = specifier.split('/').collect::<Vec<_>>();
let name_part_len = if specifier.starts_with('@') { 2 } else { 1 };
if parts.len() < name_part_len {
- return Err(generic_error(format!("Not a valid package: {}", specifier)));
+ return Err(generic_error(format!("Not a valid package: {specifier}")));
}
let name_parts = &parts[0..name_part_len];
let last_name_part = &name_parts[name_part_len - 1];
@@ -81,8 +81,7 @@ impl NpmPackageReference {
if let Some(at_index) = sub_path.rfind('@') {
let (new_sub_path, version) = sub_path.split_at(at_index);
let msg = format!(
- "Invalid package specifier 'npm:{}/{}'. Did you mean to write 'npm:{}{}/{}'?",
- name, sub_path, name, version, new_sub_path
+ "Invalid package specifier 'npm:{name}/{sub_path}'. Did you mean to write 'npm:{name}{version}/{new_sub_path}'?"
);
return Err(generic_error(msg));
}
@@ -90,8 +89,7 @@ impl NpmPackageReference {
if name.is_empty() {
let msg = format!(
- "Invalid npm specifier '{}'. Did not contain a package name.",
- original_text
+ "Invalid npm specifier '{original_text}'. Did not contain a package name."
);
return Err(generic_error(msg));
}
@@ -133,7 +131,7 @@ impl std::fmt::Display for NpmPackageReq {
impl NpmPackageReq {
pub fn from_str(text: &str) -> Result<Self, AnyError> {
// probably should do something more targeted in the future
- let reference = NpmPackageReference::from_str(&format!("npm:{}", text))?;
+ let reference = NpmPackageReference::from_str(&format!("npm:{text}"))?;
Ok(reference.req)
}
}
@@ -163,7 +161,7 @@ impl NpmVersionMatcher for NpmPackageReq {
self
.version_req
.as_ref()
- .map(|v| format!("{}", v))
+ .map(|v| format!("{v}"))
.unwrap_or_else(|| "non-prerelease".to_string())
}
}
diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs
index 4307f2b2e..9ea14061e 100644
--- a/cli/npm/resolvers/mod.rs
+++ b/cli/npm/resolvers/mod.rs
@@ -256,14 +256,13 @@ impl NpmPackageResolver {
.iter()
.collect::<HashSet<_>>() // prevent duplicates
.iter()
- .map(|p| format!("\"{}\"", p))
+ .map(|p| format!("\"{p}\""))
.collect::<Vec<_>>()
.join(", ");
return Err(custom_error(
"NoNpm",
format!(
- "Following npm specifiers were requested: {}; but --no-npm is specified.",
- fmt_reqs
+ "Following npm specifiers were requested: {fmt_reqs}; but --no-npm is specified."
),
));
}
diff --git a/cli/npm/semver/mod.rs b/cli/npm/semver/mod.rs
index a87585809..b532835e6 100644
--- a/cli/npm/semver/mod.rs
+++ b/cli/npm/semver/mod.rs
@@ -53,7 +53,7 @@ impl fmt::Display for NpmVersion {
if i > 0 {
write!(f, ".")?;
}
- write!(f, "{}", part)?;
+ write!(f, "{part}")?;
}
}
if !self.build.is_empty() {
@@ -62,7 +62,7 @@ impl fmt::Display for NpmVersion {
if i > 0 {
write!(f, ".")?;
}
- write!(f, "{}", part)?;
+ write!(f, "{part}")?;
}
}
Ok(())
@@ -143,7 +143,7 @@ impl NpmVersion {
pub fn parse(text: &str) -> Result<Self, AnyError> {
let text = text.trim();
with_failure_handling(parse_npm_version)(text)
- .with_context(|| format!("Invalid npm version '{}'.", text))
+ .with_context(|| format!("Invalid npm version '{text}'."))
}
}
@@ -218,7 +218,7 @@ impl NpmVersionReq {
pub fn parse(text: &str) -> Result<Self, AnyError> {
let text = text.trim();
with_failure_handling(parse_npm_version_req)(text)
- .with_context(|| format!("Invalid npm version requirement '{}'.", text))
+ .with_context(|| format!("Invalid npm version requirement '{text}'."))
}
}
@@ -523,7 +523,7 @@ fn nr(input: &str) -> ParseResult<u64> {
Err(err) => {
return ParseError::fail(
input,
- format!("Error parsing '{}' to u64.\n\n{:#}", result, err),
+ format!("Error parsing '{result}' to u64.\n\n{err:#}"),
)
}
};
@@ -984,9 +984,7 @@ mod tests {
let version = NpmVersion::parse(version_text).unwrap();
assert!(
req.matches(&version),
- "Checking {} satisfies {}",
- req_text,
- version_text
+ "Checking {req_text} satisfies {version_text}"
);
}
}
@@ -1083,9 +1081,7 @@ mod tests {
let version = NpmVersion::parse(version_text).unwrap();
assert!(
!req.matches(&version),
- "Checking {} not satisfies {}",
- req_text,
- version_text
+ "Checking {req_text} not satisfies {version_text}"
);
}
}
diff --git a/cli/npm/semver/specifier.rs b/cli/npm/semver/specifier.rs
index 3fdeab16d..b12a5c308 100644
--- a/cli/npm/semver/specifier.rs
+++ b/cli/npm/semver/specifier.rs
@@ -33,7 +33,7 @@ impl std::fmt::Display for SpecifierVersionReq {
impl SpecifierVersionReq {
pub fn parse(text: &str) -> Result<Self, AnyError> {
with_failure_handling(parse_npm_specifier)(text).with_context(|| {
- format!("Invalid npm specifier version requirement '{}'.", text)
+ format!("Invalid npm specifier version requirement '{text}'.")
})
}
@@ -143,7 +143,7 @@ fn nr(input: &str) -> ParseResult<u64> {
Err(err) => {
return ParseError::fail(
input,
- format!("Error parsing '{}' to u64.\n\n{:#}", result, err),
+ format!("Error parsing '{result}' to u64.\n\n{err:#}"),
)
}
};
diff --git a/cli/npm/tarball.rs b/cli/npm/tarball.rs
index 7fce69cda..758ac3ded 100644
--- a/cli/npm/tarball.rs
+++ b/cli/npm/tarball.rs
@@ -154,12 +154,12 @@ mod test {
verify_tarball_integrity(package, &Vec::new(), "sha512-test")
.unwrap_err()
.to_string(),
- format!("Tarball checksum did not match what was provided by npm registry for package@1.0.0.\n\nExpected: test\nActual: {}", actual_checksum),
+ format!("Tarball checksum did not match what was provided by npm registry for package@1.0.0.\n\nExpected: test\nActual: {actual_checksum}"),
);
assert!(verify_tarball_integrity(
package,
&Vec::new(),
- &format!("sha512-{}", actual_checksum)
+ &format!("sha512-{actual_checksum}")
)
.is_ok());
}