Skip to content

Commit 9ab1532

Browse files
committed
fix: package map bugs in exec cwd and workspace link lookup
- Fix exec command skipping package map refresh after final cwd change - Added with_cwd_and_refresh method to refresh package map when cwd changes - Ensures NODE_OPTIONS has correct --experimental-package-map for actual working directory - Fix workspace link dependency name lookup with relative paths - Normalize link paths to absolute before comparing with workspace.path - Allows relative link: targets to correctly match workspace packages in package maps
1 parent 578c179 commit 9ab1532

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/zpm/src/commands/exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Exec {
3333
Ok(ScriptEnvironment::new()?
3434
.with_project(&project)
3535
.with_package(&project, &project.active_package()?)?
36-
.with_cwd(Path::current_dir()?)
36+
.with_cwd_and_refresh(&project, Path::current_dir()?)
3737
.enable_shell_forwarding()
3838
.enable_signal_delegation()
3939
.run_script(&self.script, &self.args)

packages/zpm/src/linker/package_map.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,15 @@ fn workspace_link_dependency_names(project: &Project, tree: &ResolutionTree, loc
303303
let link_path
304304
= Path::from_str(&params.path).ok()?;
305305

306+
let link_path_abs = if link_path.is_absolute() {
307+
link_path
308+
} else {
309+
project.project_cwd.with_join(&link_path)
310+
};
311+
306312
let workspace = project.workspaces
307313
.iter()
308-
.find(|workspace| workspace.path == link_path)?;
314+
.find(|workspace| workspace.path == link_path_abs)?;
309315

310316
resolution_dependency_names(tree, &workspace.locator())
311317
}

packages/zpm/src/script.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,12 @@ impl ScriptEnvironment {
801801
self
802802
}
803803

804+
pub fn with_cwd_and_refresh(mut self, project: &Project, cwd: Path) -> Self {
805+
self.cwd = cwd;
806+
self.refresh_package_map(project);
807+
self
808+
}
809+
804810
fn install_binaries(&mut self) -> Result<Path, Error> {
805811
let hash
806812
= Hash64::from_string(&JsonDocument::to_string(&self.binaries)?);

0 commit comments

Comments
 (0)