diff --git a/packages/workspace/src/tasks-runner/run-command.spec.ts b/packages/workspace/src/tasks-runner/run-command.spec.ts index bd56dfa2af..92db1c2c57 100644 --- a/packages/workspace/src/tasks-runner/run-command.spec.ts +++ b/packages/workspace/src/tasks-runner/run-command.spec.ts @@ -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', () => { projectGraph.nodes.app1.data.targets.build.dependsOn = [ { diff --git a/packages/workspace/src/tasks-runner/run-command.ts b/packages/workspace/src/tasks-runner/run-command.ts index 652db5451c..136810d86f 100644 --- a/packages/workspace/src/tasks-runner/run-command.ts +++ b/packages/workspace/src/tasks-runner/run-command.ts @@ -173,6 +173,14 @@ function addTasksForProjectTarget( tasksMap: Map, path: string[] ) { + const task = createTask({ + project, + target, + configuration, + overrides, + errorIfCannotFindConfiguration, + }); + const dependencyConfigs = getDependencyConfigs( { project: project.name, target }, defaultDependencyConfigs, @@ -195,13 +203,6 @@ function addTasksForProjectTarget( ); } } - const task = createTask({ - project, - target, - configuration, - overrides, - errorIfCannotFindConfiguration, - }); tasksMap.set(task.id, task); } @@ -229,7 +230,7 @@ export function createTask({ if (errorIfCannotFindConfiguration && configuration && !config) { output.error({ - title: `Cannot find configuration '${configuration}' for project '${project.name}'`, + title: `Cannot find configuration '${configuration}' for project '${project.name}:${target}'`, }); process.exit(1); }