Skip to content

Commit b143507

Browse files
matz3RandomByte
authored andcommitted
refactor(project): Extract project build into own method
Allows better test assertions via spies
1 parent f1177e7 commit b143507

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

packages/project/lib/build/ProjectBuilder.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ class ProjectBuilder {
295295
if (alreadyBuilt.includes(projectName) || !(await projectBuildContext.requiresBuild())) {
296296
this.#log.skipProjectBuild(projectName, projectType);
297297
} else {
298-
this.#log.startProjectBuild(projectName, projectType);
299-
const changedResources = await projectBuildContext.runTasks();
300-
this.#log.endProjectBuild(projectName, projectType);
298+
const {changedResources} = await this._buildProject(projectBuildContext);
301299
for (const pbc of queue) {
302300
// Propagate resource changes to following projects
303301
pbc.getBuildCache().dependencyResourcesChanged(changedResources);
@@ -389,9 +387,7 @@ class ProjectBuilder {
389387
continue;
390388
}
391389

392-
this.#log.startProjectBuild(projectName, projectType);
393-
const changedResources = await projectBuildContext.runTasks();
394-
this.#log.endProjectBuild(projectName, projectType);
390+
const {changedResources} = await this._buildProject(projectBuildContext);
395391
for (const pbc of queue) {
396392
// Propagate resource changes to following projects
397393
pbc.getBuildCache().dependencyResourcesChanged(changedResources);
@@ -420,6 +416,18 @@ class ProjectBuilder {
420416
await Promise.all(pWrites);
421417
}
422418

419+
async _buildProject(projectBuildContext) {
420+
const project = projectBuildContext.getProject();
421+
const projectName = project.getName();
422+
const projectType = project.getType();
423+
424+
this.#log.startProjectBuild(projectName, projectType);
425+
const changedResources = await projectBuildContext.runTasks();
426+
this.#log.endProjectBuild(projectName, projectType);
427+
428+
return {changedResources};
429+
}
430+
423431
async _getProjectFilter({
424432
dependencyIncludes,
425433
explicitIncludes,

0 commit comments

Comments
 (0)