mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(npm): "not implemented scheme" message should properly show the scheme (#18209)
This commit is contained in:
parent
3a46a89e34
commit
ca51f4f6c0
1 changed files with 17 additions and 17 deletions
|
@ -44,7 +44,7 @@ pub enum PackageJsonDepValueParseError {
|
||||||
SchemeValue(#[from] PackageJsonDepNpmSchemeValueParseError),
|
SchemeValue(#[from] PackageJsonDepNpmSchemeValueParseError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Specifier(#[from] NpmVersionReqSpecifierParseError),
|
Specifier(#[from] NpmVersionReqSpecifierParseError),
|
||||||
#[error("Not implemented scheme: {scheme}")]
|
#[error("Not implemented scheme '{scheme}'")]
|
||||||
Unsupported { scheme: String },
|
Unsupported { scheme: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ pub fn get_local_package_json_version_reqs(
|
||||||
|| value.starts_with("https:")
|
|| value.starts_with("https:")
|
||||||
{
|
{
|
||||||
return Err(PackageJsonDepValueParseError::Unsupported {
|
return Err(PackageJsonDepValueParseError::Unsupported {
|
||||||
scheme: key.split(':').next().unwrap().to_string(),
|
scheme: value.split(':').next().unwrap().to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let (name, version_req) = parse_dep_entry_name_and_raw_version(key, value)
|
let (name, version_req) = parse_dep_entry_name_and_raw_version(key, value)
|
||||||
|
@ -254,39 +254,39 @@ mod test {
|
||||||
let mut package_json = PackageJson::empty(PathBuf::from("/package.json"));
|
let mut package_json = PackageJson::empty(PathBuf::from("/package.json"));
|
||||||
package_json.dependencies = Some(HashMap::from([
|
package_json.dependencies = Some(HashMap::from([
|
||||||
("test".to_string(), "1".to_string()),
|
("test".to_string(), "1".to_string()),
|
||||||
("work".to_string(), "workspace:1.1.1".to_string()),
|
("work-test".to_string(), "workspace:1.1.1".to_string()),
|
||||||
("file".to_string(), "file:something".to_string()),
|
("file-test".to_string(), "file:something".to_string()),
|
||||||
("git".to_string(), "git:something".to_string()),
|
("git-test".to_string(), "git:something".to_string()),
|
||||||
("http".to_string(), "http://something".to_string()),
|
("http-test".to_string(), "http://something".to_string()),
|
||||||
("https".to_string(), "https://something".to_string()),
|
("https-test".to_string(), "https://something".to_string()),
|
||||||
]));
|
]));
|
||||||
let result = get_local_package_json_version_reqs_for_tests(&package_json);
|
let result = get_local_package_json_version_reqs_for_tests(&package_json);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
BTreeMap::from([
|
BTreeMap::from([
|
||||||
(
|
(
|
||||||
"file".to_string(),
|
"file-test".to_string(),
|
||||||
Err("Not implemented scheme: file".to_string()),
|
Err("Not implemented scheme 'file'".to_string()),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"git".to_string(),
|
"git-test".to_string(),
|
||||||
Err("Not implemented scheme: git".to_string()),
|
Err("Not implemented scheme 'git'".to_string()),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"http".to_string(),
|
"http-test".to_string(),
|
||||||
Err("Not implemented scheme: http".to_string()),
|
Err("Not implemented scheme 'http'".to_string()),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"https".to_string(),
|
"https-test".to_string(),
|
||||||
Err("Not implemented scheme: https".to_string()),
|
Err("Not implemented scheme 'https'".to_string()),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
Ok(NpmPackageReq::from_str("test@1").unwrap())
|
Ok(NpmPackageReq::from_str("test@1").unwrap())
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"work".to_string(),
|
"work-test".to_string(),
|
||||||
Err("Not implemented scheme: work".to_string()),
|
Err("Not implemented scheme 'workspace'".to_string()),
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue