mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(install): support installing npm package with alias (#26246)
Just tried this out today and it wasn't properly implemented in https://github.com/denoland/deno/pull/24156
This commit is contained in:
parent
f3530c858f
commit
c5449d71da
9 changed files with 48 additions and 6 deletions
|
@ -363,7 +363,14 @@ fn package_json_dependency_entry(
|
|||
selected: SelectedPackage,
|
||||
) -> (String, String) {
|
||||
if let Some(npm_package) = selected.package_name.strip_prefix("npm:") {
|
||||
(npm_package.into(), selected.version_req)
|
||||
if selected.import_name == npm_package {
|
||||
(npm_package.into(), selected.version_req)
|
||||
} else {
|
||||
(
|
||||
selected.import_name,
|
||||
format!("npm:{}@{}", npm_package, selected.version_req),
|
||||
)
|
||||
}
|
||||
} else if let Some(jsr_package) = selected.package_name.strip_prefix("jsr:") {
|
||||
let jsr_package = jsr_package.strip_prefix('@').unwrap_or(jsr_package);
|
||||
let scope_replaced = jsr_package.replace('/', "__");
|
||||
|
@ -741,6 +748,9 @@ fn generate_imports(mut packages_to_version: Vec<(String, String)>) -> String {
|
|||
let mut contents = vec![];
|
||||
let len = packages_to_version.len();
|
||||
for (index, (package, version)) in packages_to_version.iter().enumerate() {
|
||||
if index == 0 {
|
||||
contents.push(String::new()); // force a newline at the start
|
||||
}
|
||||
// TODO(bartlomieju): fix it, once we start support specifying version on the cli
|
||||
contents.push(format!("\"{}\": \"{}\"", package, version));
|
||||
if index != len - 1 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue