From d168926a976522a19c077d2865367cbb95e721ed Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Fri, 18 Aug 2023 17:31:59 -0400 Subject: [PATCH] chore(core): change retrieveProjectConfigurationPaths to async (#18717) (cherry picked from commit 7d4e2fec10530059366ab71f60f5d0cc5dfb6757) --- .../nx/src/migrations/update-15-1-0/set-project-names.ts | 5 ++++- .../project-graph/utils/retrieve-workspace-files.spec.ts | 8 ++++---- .../src/project-graph/utils/retrieve-workspace-files.ts | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/nx/src/migrations/update-15-1-0/set-project-names.ts b/packages/nx/src/migrations/update-15-1-0/set-project-names.ts index d15cd1b5b2c46..ec6665a2b2895 100644 --- a/packages/nx/src/migrations/update-15-1-0/set-project-names.ts +++ b/packages/nx/src/migrations/update-15-1-0/set-project-names.ts @@ -7,7 +7,10 @@ import { retrieveProjectConfigurationPaths } from '../../project-graph/utils/ret export default async function (tree: Tree) { const nxJson = readNxJson(tree); - const projectFiles = retrieveProjectConfigurationPaths(tree.root, nxJson); + const projectFiles = await retrieveProjectConfigurationPaths( + tree.root, + nxJson + ); const projectJsons = projectFiles.filter((f) => f.endsWith('project.json')); for (let f of projectJsons) { diff --git a/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts b/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts index c8b01962308a7..59dcecf842782 100644 --- a/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts +++ b/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts @@ -24,10 +24,10 @@ describe('retrieveProjectConfigurationPaths', () => { name: 'project-1', }) ); - expect(retrieveProjectConfigurationPaths(fs.tempDir, {})).not.toContain( - 'not-projects/project.json' - ); - expect(retrieveProjectConfigurationPaths(fs.tempDir, {})).toContain( + expect( + await retrieveProjectConfigurationPaths(fs.tempDir, {}) + ).not.toContain('not-projects/project.json'); + expect(await retrieveProjectConfigurationPaths(fs.tempDir, {})).toContain( 'projects/project.json' ); }); diff --git a/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts b/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts index 59d6c7f5ceb9d..57cf611b062c6 100644 --- a/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts +++ b/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts @@ -182,13 +182,13 @@ function _retrieveProjectConfigurations( }; } -export function retrieveProjectConfigurationPaths( +export async function retrieveProjectConfigurationPaths( root: string, nxJson: NxJsonConfiguration -): string[] { +): Promise { const projectGlobPatterns = configurationGlobs( root, - loadNxPluginsSync(nxJson?.plugins ?? [], getNxRequirePaths(root), root) + await loadNxPlugins(nxJson?.plugins ?? [], getNxRequirePaths(root), root) ); const { getProjectConfigurationFiles } = require('../../native') as typeof import('../../native');