-
Notifications
You must be signed in to change notification settings - Fork 23
/
BuildContext.js
67 lines (58 loc) · 1.36 KB
/
BuildContext.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Context of a build process
*
* @private
* @memberof module:@ui5/builder.builder
*/
class BuildContext {
constructor({rootProject}) {
this.projectBuildContexts = [];
this.rootProject = rootProject;
}
getRootProject() {
return this.rootProject;
}
createProjectContext({project, resources}) {
const projectBuildContext = new ProjectBuildContext({
buildContext: this,
project,
resources
});
this.projectBuildContexts.push(projectBuildContext);
return projectBuildContext;
}
async executeCleanupTasks() {
await Promise.all(this.projectBuildContexts.map((ctx) => {
return ctx.executeCleanupTasks();
}));
}
}
/**
* Build context of a single project. Always part of an overall
* [Build Context]{@link module:@ui5/builder.builder.BuildContext}
*
* @private
* @memberof module:@ui5/builder.builder
*/
class ProjectBuildContext {
constructor({buildContext, project, resources}) {
this._buildContext = buildContext;
this._project = project;
// this.resources = resources;
this.queues = {
cleanup: []
};
}
isRootProject() {
return this._project === this._buildContext.getRootProject();
}
registerCleanupTask(callback) {
this.queues.cleanup.push(callback);
}
async executeCleanupTasks() {
await Promise.all(this.queues.cleanup.map((callback) => {
return callback();
}));
}
}
module.exports = BuildContext;