Skip to content

Commit

Permalink
refactor: Use simpler root package.json check. (#9382)
Browse files Browse the repository at this point in the history
### Description

Following up on Chris' comment on #9378. I didn't see it before I hit
merge because I was on mobile.
  • Loading branch information
anthonyshew authored Nov 5, 2024
1 parent 21863ad commit 7d99609
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions crates/turborepo-repository/src/package_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,14 @@ impl PackageGraph {

#[tracing::instrument(skip(self))]
pub fn validate(&self) -> Result<(), Error> {
for info in self.packages.values() {
for (package_name, info) in self.packages.iter() {
if matches!(package_name, PackageName::Root) {
continue;
}
let name = info.package_json.name.as_deref();
let package_json_path = self.repo_root.resolve(info.package_json_path());
match name {
Some("") => {
return Err(Error::PackageJsonMissingName(package_json_path));
}
None => {
// We don't need to require a name for the root package.json.
if package_json_path == self.repo_root.join_component("package.json") {
continue;
}

Some("") | None => {
let package_json_path = self.repo_root.resolve(info.package_json_path());
return Err(Error::PackageJsonMissingName(package_json_path));
}
Some(_) => continue,
Expand Down

0 comments on commit 7d99609

Please sign in to comment.