From 33aa9dbff9bf0b604fa791869b8c20356685a1a9 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Wed, 27 Mar 2024 00:05:22 +0100 Subject: [PATCH] fix: :bug: link root dependencies to their dependents aswell --- src/linking_file.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/linking_file.rs b/src/linking_file.rs index 356910b..ffe87bc 100644 --- a/src/linking_file.rs +++ b/src/linking_file.rs @@ -129,6 +129,7 @@ pub(crate) fn link, Q: AsRef>( destination_dir: P, parent_dependency_packages_dir: Q, only_name: bool, + as_root: bool, ) -> Result<(), LinkingError> { let (_, source_dir) = resolved_pkg.directory(project.path()); let file = Manifest::from_path(&source_dir)?; @@ -152,10 +153,10 @@ pub(crate) fn link, Q: AsRef>( .get(&pkg_name) .and_then(|v| v.get(resolved_pkg.pkg_ref.version())) { - Some(specifier) => project.path().join(packages_folder( + Some(specifier) if as_root => project.path().join(packages_folder( specifier.realm().copied().unwrap_or_default(), )), - None => destination_dir.as_ref().to_path_buf(), + _ => destination_dir.as_ref().to_path_buf(), }; let destination_file = destination_dir.join(format!( @@ -282,6 +283,7 @@ impl Project { &container_dir, &self.path().join(resolved_pkg.packages_folder()), !is_duplicate_in(dep_name.name(), &resolved_pkg_dep_names), + false, ) .map_err(|e| { LinkingDependenciesError( @@ -295,7 +297,8 @@ impl Project { } if root_deps.contains(&name) { - let linking_dir = &self.path().join(resolved_pkg.packages_folder()); + let specifier = lockfile.root_specifier(resolved_pkg).unwrap(); + let linking_dir = &self.path().join(packages_folder(specifier.realm().copied().unwrap_or_default())); debug!( "linking root package {name}@{version} to directory {}", @@ -307,8 +310,9 @@ impl Project { resolved_pkg, lockfile, linking_dir, - linking_dir, + self.path().join(resolved_pkg.packages_folder()), !is_duplicate_in(name.name(), &root_dep_names), + true, ) .map_err(|e| { LinkingDependenciesError(