Skip to content

Commit

Permalink
fix(common): fix wrong glob used when listing project files to build …
Browse files Browse the repository at this point in the history
…project graph

This caused an issue when the glob is composed of only 1 file, like for `nx-flutter`.
Closes #227
  • Loading branch information
tinesoft committed Jun 16, 2024
1 parent f99fa77 commit 8d5fd7f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/common/src/lib/workspace/project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ function getDependenciesForProject(
return dependencies;
}

function getProjectFilesGlob(projectFiles: string[]): string {
return projectFiles.length > 1
? `**/{${projectFiles.join(',')}}`
: `**/${projectFiles[0]}`;
}

// Project Graph V1

export function getProjectGraph(
Expand Down Expand Up @@ -169,7 +175,7 @@ export const createNodesFor = <T = unknown>(
pluginName: string
) =>
[
`**/{${projectFiles.join(',')}}` as string,
getProjectFilesGlob(projectFiles),
(
file: string,
options: T,
Expand Down Expand Up @@ -216,11 +222,11 @@ export const createDependenciesIf = (

let dependencies: RawProjectGraphDependency[] = [];

const projectFilePattern = `**/{${projectFiles.join(',')}}`;
const projectFileGlob = getProjectFilesGlob(projectFiles);
for (const source in ctx.filesToProcess.projectFileMap) {
const changed = ctx.filesToProcess.projectFileMap[source];
for (const file of changed) {
if (minimatch(file.file, projectFilePattern)) {
if (minimatch(file.file, projectFileGlob)) {
// we only create the workspace map once and only if changed file is of interest
workspace ??= getPackageInfosForNxProjects(
pluginName,
Expand Down

0 comments on commit 8d5fd7f

Please sign in to comment.