fix(core): excluding task dependencies breaks task sorting
This commit is contained in:
parent
d57a4d06aa
commit
84fb879c00
@ -1,4 +1,4 @@
|
|||||||
import { ProjectGraph } from '../config/project-graph';
|
import { DependencyType, ProjectGraph } from '../config/project-graph';
|
||||||
import { createTaskGraph } from 'nx/src/tasks-runner/create-task-graph';
|
import { createTaskGraph } from 'nx/src/tasks-runner/create-task-graph';
|
||||||
|
|
||||||
describe('createTaskGraph', () => {
|
describe('createTaskGraph', () => {
|
||||||
@ -741,14 +741,31 @@ describe('createTaskGraph', () => {
|
|||||||
files: [],
|
files: [],
|
||||||
targets: {
|
targets: {
|
||||||
build: {
|
build: {
|
||||||
dependsOn: [{ target: 'test', projects: 'self' }],
|
dependsOn: [
|
||||||
|
{ target: 'prebuild', projects: 'self' },
|
||||||
|
{ target: 'build', projects: 'dependencies' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
test: {},
|
prebuild: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
app2: {
|
||||||
|
name: 'app2',
|
||||||
|
type: 'app',
|
||||||
|
data: {
|
||||||
|
root: 'app2-root',
|
||||||
|
files: [],
|
||||||
|
targets: {
|
||||||
|
build: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dependencies: {},
|
dependencies: {
|
||||||
|
app1: [{ source: 'app1', target: 'app2', type: DependencyType.static }],
|
||||||
|
app2: [],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskGraph = createTaskGraph(
|
const taskGraph = createTaskGraph(
|
||||||
@ -782,5 +799,49 @@ describe('createTaskGraph', () => {
|
|||||||
'app1:build': [],
|
'app1:build': [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const taskGraph2 = createTaskGraph(
|
||||||
|
projectGraph,
|
||||||
|
{},
|
||||||
|
['app1', 'app2'],
|
||||||
|
['build'],
|
||||||
|
'development',
|
||||||
|
{
|
||||||
|
__overrides_unparsed__: [],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
// prebuild should also be in here
|
||||||
|
expect(taskGraph2).toEqual({
|
||||||
|
roots: ['app2:build'],
|
||||||
|
tasks: {
|
||||||
|
'app1:build': {
|
||||||
|
id: 'app1:build',
|
||||||
|
target: {
|
||||||
|
project: 'app1',
|
||||||
|
target: 'build',
|
||||||
|
},
|
||||||
|
overrides: {
|
||||||
|
__overrides_unparsed__: [],
|
||||||
|
},
|
||||||
|
projectRoot: 'app1-root',
|
||||||
|
},
|
||||||
|
'app2:build': {
|
||||||
|
id: 'app2:build',
|
||||||
|
target: {
|
||||||
|
project: 'app2',
|
||||||
|
target: 'build',
|
||||||
|
},
|
||||||
|
overrides: {
|
||||||
|
__overrides_unparsed__: [],
|
||||||
|
},
|
||||||
|
projectRoot: 'app2-root',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
'app1:build': ['app2:build'],
|
||||||
|
'app2:build': []
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -44,12 +44,28 @@ export class ProcessTasks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!excludeTaskDependencies) {
|
// used when excluding tasks
|
||||||
for (const taskId of Object.keys(this.tasks)) {
|
const initialTasks = { ...this.tasks };
|
||||||
const task = this.tasks[taskId];
|
|
||||||
this.processTask(task, task.target.project, configuration, overrides);
|
for (const taskId of Object.keys(this.tasks)) {
|
||||||
|
const task = this.tasks[taskId];
|
||||||
|
this.processTask(task, task.target.project, configuration, overrides);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludeTaskDependencies) {
|
||||||
|
for (let t of Object.keys(this.tasks)) {
|
||||||
|
if (!initialTasks[t]) {
|
||||||
|
delete this.tasks[t];
|
||||||
|
delete this.dependencies[t];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let d of Object.keys(this.dependencies)) {
|
||||||
|
this.dependencies[d] = this.dependencies[d].filter(
|
||||||
|
(dd) => !!initialTasks[dd]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.keys(this.dependencies).filter(
|
return Object.keys(this.dependencies).filter(
|
||||||
(d) => this.dependencies[d].length === 0
|
(d) => this.dependencies[d].length === 0
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user