Skip to content

Commit

Permalink
fix(core): prepare Angular specific error only before throwing it
Browse files Browse the repository at this point in the history
This commit updates the implementation of the `readCachedProjectGraph` function and
checks whether the `angular.json` file exists only when it's required, throwing the error
afterward. This removes the redundant call to `statSync` if we encounter a cached graph.
  • Loading branch information
arturovt committed Aug 30, 2023
1 parent 83f2001 commit 8cede1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/nx/src/project-graph/project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import { readNxJson } from '../config/nx-json';
*/
export function readCachedProjectGraph(): ProjectGraph {
const projectGraphCache: ProjectGraph = readProjectGraphCache();
const angularSpecificError = fileExists(`${workspaceRoot}/angular.json`)
? stripIndents`
if (!projectGraphCache) {
const angularSpecificError = fileExists(`${workspaceRoot}/angular.json`)
? stripIndents`
Make sure invoke 'node ./decorate-angular-cli.js' in your postinstall script.
The decorated CLI will compute the project graph.
'ng --help' should say 'Smart, Fast and Extensible Build System'.
`
: '';
if (!projectGraphCache) {
: '';

throw new Error(stripIndents`
[readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
Expand Down

0 comments on commit 8cede1f

Please sign in to comment.