feat(core): error when a project graph plugin fails (#16095)

This commit is contained in:
Craigory Coppola 2023-04-06 11:25:35 -04:00 committed by GitHub
parent e81bdd4c1e
commit ad6ec996f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,6 @@ import {
} from '../config/project-graph'; } from '../config/project-graph';
import { readJsonFile } from '../utils/fileutils'; import { readJsonFile } from '../utils/fileutils';
import { NxJsonConfiguration } from '../config/nx-json'; import { NxJsonConfiguration } from '../config/nx-json';
import { logger } from '../utils/logger';
import { ProjectGraphBuilder } from './project-graph-builder'; import { ProjectGraphBuilder } from './project-graph-builder';
import { import {
ProjectConfiguration, ProjectConfiguration,
@ -235,15 +234,12 @@ async function updateProjectGraphWithPlugins(
try { try {
graph = await plugin.processProjectGraph(graph, context); graph = await plugin.processProjectGraph(graph, context);
} catch (e) { } catch (e) {
const message = `Failed to process the project graph with "${plugin.name}". This will error in the future!`; let message = `Failed to process the project graph with "${plugin.name}".`;
if (process.env.NX_VERBOSE_LOGGING === 'true') { if (e instanceof Error) {
console.error(e); e.message = message + '\n' + e.message;
logger.error(message); throw e;
return graph;
} else {
logger.warn(message);
logger.warn(`Run with NX_VERBOSE_LOGGING=true to see the error.`);
} }
throw new Error(message);
} }
} }
return graph; return graph;