fix(testing): warn and default if sourceRoot isn't set for ng CT (#13940)

This commit is contained in:
Caleb Ukle 2022-12-21 11:59:22 -06:00 committed by GitHub
parent 3a2721b45d
commit 88f860dff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,11 +231,20 @@ function normalizeBuildTargetOptions(
buildOptions.scripts = []; buildOptions.scripts = [];
buildOptions.stylePreprocessorOptions = { includePaths: [] }; buildOptions.stylePreprocessorOptions = { includePaths: [] };
} }
const { root, sourceRoot } =
const config =
buildContext.projectGraph.nodes[buildContext.projectName]?.data; buildContext.projectGraph.nodes[buildContext.projectName]?.data;
if (!config.sourceRoot) {
logger.warn(stripIndents`Unable to find the 'sourceRoot' in the project configuration.
Will set 'sourceRoot' to '${config.root}/src'
Note: this may fail, setting the correct 'sourceRoot' for ${buildContext.projectName} in the project.json file will ensure the correct value is used.`);
config.sourceRoot = joinPathFragments(config.root, 'src');
}
return { return {
root: joinPathFragments(offset, root), root: joinPathFragments(offset, config.root),
sourceRoot: joinPathFragments(offset, sourceRoot), sourceRoot: joinPathFragments(offset, config.sourceRoot),
buildOptions, buildOptions,
}; };
} }