fix(core): error when an invalid target/configuration is passed (#5447)
This commit is contained in:
parent
ae5722eb50
commit
bc7af1d4a3
@ -330,6 +330,44 @@ describe('createTasksForProjectToRun', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw an error for an invalid target', () => {
|
||||||
|
spyOn(process, 'exit').and.throwError('');
|
||||||
|
try {
|
||||||
|
createTasksForProjectToRun(
|
||||||
|
[projectGraph.nodes.app1],
|
||||||
|
{
|
||||||
|
target: 'invalid',
|
||||||
|
configuration: undefined,
|
||||||
|
overrides: {},
|
||||||
|
},
|
||||||
|
projectGraph,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
fail();
|
||||||
|
} catch (e) {
|
||||||
|
expect(process.exit).toHaveBeenCalledWith(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error for an invalid configuration for the initiating project', () => {
|
||||||
|
spyOn(process, 'exit').and.throwError('');
|
||||||
|
try {
|
||||||
|
createTasksForProjectToRun(
|
||||||
|
[projectGraph.nodes.app1],
|
||||||
|
{
|
||||||
|
target: 'serve',
|
||||||
|
configuration: 'invalid',
|
||||||
|
overrides: {},
|
||||||
|
},
|
||||||
|
projectGraph,
|
||||||
|
'app1'
|
||||||
|
);
|
||||||
|
fail();
|
||||||
|
} catch (e) {
|
||||||
|
expect(process.exit).toHaveBeenCalledWith(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error for circular dependencies', () => {
|
it('should throw an error for circular dependencies', () => {
|
||||||
projectGraph.nodes.app1.data.targets.build.dependsOn = [
|
projectGraph.nodes.app1.data.targets.build.dependsOn = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -173,6 +173,14 @@ function addTasksForProjectTarget(
|
|||||||
tasksMap: Map<string, Task>,
|
tasksMap: Map<string, Task>,
|
||||||
path: string[]
|
path: string[]
|
||||||
) {
|
) {
|
||||||
|
const task = createTask({
|
||||||
|
project,
|
||||||
|
target,
|
||||||
|
configuration,
|
||||||
|
overrides,
|
||||||
|
errorIfCannotFindConfiguration,
|
||||||
|
});
|
||||||
|
|
||||||
const dependencyConfigs = getDependencyConfigs(
|
const dependencyConfigs = getDependencyConfigs(
|
||||||
{ project: project.name, target },
|
{ project: project.name, target },
|
||||||
defaultDependencyConfigs,
|
defaultDependencyConfigs,
|
||||||
@ -195,13 +203,6 @@ function addTasksForProjectTarget(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const task = createTask({
|
|
||||||
project,
|
|
||||||
target,
|
|
||||||
configuration,
|
|
||||||
overrides,
|
|
||||||
errorIfCannotFindConfiguration,
|
|
||||||
});
|
|
||||||
tasksMap.set(task.id, task);
|
tasksMap.set(task.id, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ export function createTask({
|
|||||||
|
|
||||||
if (errorIfCannotFindConfiguration && configuration && !config) {
|
if (errorIfCannotFindConfiguration && configuration && !config) {
|
||||||
output.error({
|
output.error({
|
||||||
title: `Cannot find configuration '${configuration}' for project '${project.name}'`,
|
title: `Cannot find configuration '${configuration}' for project '${project.name}:${target}'`,
|
||||||
});
|
});
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user