Skip to content

Commit b9856e8

Browse files
committed
[INTERNAL] Adopt to task- and middlewareRepository refactorings
taskRepository refactoring: SAP/ui5-builder#438 middlewareRepository refactoring: SAP/ui5-server#302
1 parent cb3f092 commit b9856e8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/projectPreprocessor.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,12 @@ class ProjectPreprocessor {
587587
const taskRepository = require("@ui5/builder").tasks.taskRepository;
588588

589589
const taskPath = path.join(extension.path, extension.task.path);
590-
const task = require(taskPath); // throws if not found
591590

592-
taskRepository.addTask(extension.metadata.name, task);
591+
taskRepository.addTask({
592+
name: extension.metadata.name,
593+
specVersion: extension.specVersion,
594+
taskPath,
595+
});
593596
}
594597

595598
handleServerMiddleware(extension) {
@@ -602,7 +605,11 @@ class ProjectPreprocessor {
602605
const {middlewareRepository} = require("@ui5/server");
603606

604607
const middlewarePath = path.join(extension.path, extension.middleware.path);
605-
middlewareRepository.addMiddleware(extension.metadata.name, middlewarePath);
608+
middlewareRepository.addMiddleware({
609+
name: extension.metadata.name,
610+
specVersion: extension.specVersion,
611+
middlewarePath
612+
});
606613
}
607614

608615
async validateAndNormalizeExistingProject(project) {

test/lib/extensions.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ test("Project with task extension dependency", (t) => {
616616
});
617617
});
618618

619-
test("Project with task extension dependency - task module not found", async (t) => {
619+
test("Project with task extension dependency - does not throw for invalid task path", async (t) => {
620620
// "project-type" extension handling not yet implemented => test currently checks for error
621621
const tree = {
622622
id: "application.a",
@@ -630,7 +630,7 @@ test("Project with task extension dependency - task module not found", async (t)
630630
kind: "extension",
631631
type: "task",
632632
metadata: {
633-
name: "task.a"
633+
name: "task.b"
634634
},
635635
task: {
636636
path: "task.not.existing.js"
@@ -643,8 +643,7 @@ test("Project with task extension dependency - task module not found", async (t)
643643
name: "xy"
644644
}
645645
};
646-
const error = await t.throwsAsync(projectPreprocessor.processTree(tree));
647-
t.regex(error.message, /^Cannot find module.*/, "Rejected with error");
646+
await t.notThrowsAsync(projectPreprocessor.processTree(tree));
648647
});
649648

650649

0 commit comments

Comments
 (0)