fix(core): handle project graph plugins not providing optional projectFilePatterns property (#8290)

This commit is contained in:
Leosvel Pérez Espinosa 2021-12-23 17:09:35 +00:00 committed by GitHub
parent 419948015e
commit d3f4613687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,17 +64,19 @@ export function mergePluginTargetsWithNxTargets(
): Record<string, TargetConfiguration> { ): Record<string, TargetConfiguration> {
let newTargets: Record<string, TargetConfiguration> = {}; let newTargets: Record<string, TargetConfiguration> = {};
for (const plugin of plugins) { for (const plugin of plugins) {
if (!plugin.projectFilePatterns?.length || !plugin.registerProjectTargets) {
continue;
}
const projectFiles = sync(`+(${plugin.projectFilePatterns.join('|')})`, { const projectFiles = sync(`+(${plugin.projectFilePatterns.join('|')})`, {
cwd: join(appRootPath, projectRoot), cwd: join(appRootPath, projectRoot),
}); });
for (const projectFile of projectFiles) { for (const projectFile of projectFiles) {
if (plugin.registerProjectTargets) {
newTargets = { newTargets = {
...newTargets, ...newTargets,
...plugin.registerProjectTargets(join(projectRoot, projectFile)), ...plugin.registerProjectTargets(join(projectRoot, projectFile)),
}; };
} }
} }
}
return { ...newTargets, ...targets }; return { ...newTargets, ...targets };
} }