mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(npm): better error is version is specified after subpath (#16131)
This commit is contained in:
parent
8e1b2fca59
commit
5b097fd7e5
5 changed files with 40 additions and 4 deletions
|
@ -77,6 +77,18 @@ impl NpmPackageReference {
|
|||
} else {
|
||||
Some(parts[name_part_len..].join("/"))
|
||||
};
|
||||
|
||||
if let Some(sub_path) = &sub_path {
|
||||
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
|
||||
);
|
||||
return Err(generic_error(msg));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(NpmPackageReference {
|
||||
req: NpmPackageReq { name, version_req },
|
||||
sub_path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue