Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak0085 committed Jun 14, 2024
2 parents fe9f75d + f431d0a commit 9b73489
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
21 changes: 1 addition & 20 deletions packages/nx/src/project-graph/utils/normalize-project-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function normalizeProjectNodes(
partialProjectGraphNodes
);

p.targets = normalizeProjectTargets(p, key);
p.targets ??= {};

// TODO: remove in v16
const projectType =
Expand Down Expand Up @@ -80,25 +80,6 @@ export async function normalizeProjectNodes(
});
}

/**
* Apply target defaults and normalization
*/
export function normalizeProjectTargets(
project: ProjectConfiguration,
projectName: string
): Record<string, TargetConfiguration> {
// Any node on the graph will have a targets object, it just may be empty
const targets = project.targets ?? {};

for (const target in targets) {
if (!targets[target].command && !targets[target].executor) {
delete targets[target];
continue;
}
}
return targets;
}

export function normalizeImplicitDependencies(
source: string,
implicitDependencies: ProjectConfiguration['implicitDependencies'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,21 @@ function validateAndNormalizeProjectRootMap(
);

if (
// If the target has no executor or command, it doesn't do anything
!project.targets[targetName].executor &&
!project.targets[targetName].command
) {
delete project.targets[targetName];
// But it may have dependencies that do something
if (
project.targets[targetName].dependsOn &&
project.targets[targetName].dependsOn.length > 0
) {
project.targets[targetName].executor = 'nx:noop';
} else {
// If it does nothing, and has no depenencies,
// we can remove it.
delete project.targets[targetName];
}
}
}
}
Expand Down

0 comments on commit 9b73489

Please sign in to comment.