Skip to content

Commit

Permalink
fix(core): readRawWorkspaceJson should keep workspace cache up to date (
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Oct 11, 2022
1 parent 834e2db commit ad79453
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/nx/src/generators/utils/project-configuration.ts
Expand Up @@ -465,6 +465,7 @@ function findDeletedProjects(tree: Tree) {
}

let staticFSWorkspace: RawProjectsConfigurations;
let cachedTree: Tree;
function readRawWorkspaceJson(tree: Tree): RawProjectsConfigurations {
const path = getWorkspacePath(tree);
if (path && tree.exists(path)) {
Expand All @@ -477,13 +478,14 @@ function readRawWorkspaceJson(tree: Tree): RawProjectsConfigurations {
findCreatedProjects(tree),
(file) => readJson(tree, file)
).projects;
// We already have built a cache
if (!staticFSWorkspace) {
// We already have built a cache but need to confirm it's the same tree
if (!staticFSWorkspace || tree !== cachedTree) {
staticFSWorkspace = buildWorkspaceConfigurationFromGlobs(
nxJson,
[...globForProjectFiles(tree.root, nxJson)],
(file) => readJson(tree, file)
);
cachedTree = tree;
}
const projects = { ...staticFSWorkspace.projects, ...createdProjects };
findDeletedProjects(tree).forEach((file) => {
Expand All @@ -498,10 +500,11 @@ function readRawWorkspaceJson(tree: Tree): RawProjectsConfigurations {
delete projects[matchingStaticProject[0]];
}
});
return {
staticFSWorkspace = {
...staticFSWorkspace,
projects,
};
return staticFSWorkspace;
}
}

Expand Down

1 comment on commit ad79453

@vercel
Copy link

@vercel vercel bot commented on ad79453 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.