mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
feat(lockfile): add redirects to the lockfile (#20262)
This commit is contained in:
parent
bdc91211b0
commit
c4451d3076
5 changed files with 136 additions and 9 deletions
|
@ -320,8 +320,40 @@ impl ModuleGraphBuilder {
|
|||
self.resolver.force_top_level_package_json_install().await?;
|
||||
}
|
||||
|
||||
// add the lockfile redirects to the graph if it's the first time executing
|
||||
if graph.redirects.is_empty() {
|
||||
if let Some(lockfile) = &self.lockfile {
|
||||
let lockfile = lockfile.lock();
|
||||
for (from, to) in &lockfile.content.redirects {
|
||||
if let Ok(from) = ModuleSpecifier::parse(from) {
|
||||
if let Ok(to) = ModuleSpecifier::parse(to) {
|
||||
if !matches!(from.scheme(), "file" | "npm")
|
||||
&& !matches!(to.scheme(), "file" | "npm")
|
||||
{
|
||||
graph.redirects.insert(from, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
graph.build(roots, loader, options).await;
|
||||
|
||||
// add the redirects in the graph to the lockfile
|
||||
if !graph.redirects.is_empty() {
|
||||
if let Some(lockfile) = &self.lockfile {
|
||||
let graph_redirects = graph
|
||||
.redirects
|
||||
.iter()
|
||||
.filter(|(from, _)| !matches!(from.scheme(), "npm" | "file"));
|
||||
let mut lockfile = lockfile.lock();
|
||||
for (from, to) in graph_redirects {
|
||||
lockfile.insert_redirect(from.to_string(), to.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that the top level package.json is installed if a
|
||||
// specifier was matched in the package.json
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue