diff --git a/crates/turborepo-repository/src/package_manager/mod.rs b/crates/turborepo-repository/src/package_manager/mod.rs index 85f9c7fba785e..46dc2a6bf76b5 100644 --- a/crates/turborepo-repository/src/package_manager/mod.rs +++ b/crates/turborepo-repository/src/package_manager/mod.rs @@ -136,7 +136,11 @@ impl WorkspaceGlobs { .iter() .map(|s| { let mut s: String = s.clone(); - s.push_str("/package.json"); + if s.ends_with('/') { + s.push_str("package.json"); + } else { + s.push_str("/package.json"); + } s }) .collect::>(); @@ -870,4 +874,14 @@ mod tests { assert_eq!(nested.workspaces.as_ref(), vec!["packages/**"]); Ok(()) } + + #[test] + fn test_workspace_globs_trailing_slash() { + let globs = + WorkspaceGlobs::new(vec!["scripts/", "packages/**"], vec!["package/template"]).unwrap(); + assert_eq!( + &globs.package_json_inclusions, + &["scripts/package.json", "packages/**/package.json"] + ); + } }