Skip to content

Commit

Permalink
[FIX] Consider configPath when autoDetectType (#617)
Browse files Browse the repository at this point in the history
fixes: #595
  • Loading branch information
d3xter666 committed Oct 17, 2023
1 parent ecf8680 commit 92847bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ export default class Framework {
if (this.config.ui5.type) {
return;
}
const filePath = path.join(this.config.basePath, "ui5.yaml");
const {ui5: {configPath}, basePath} = this.config;
const filePath = configPath ?
path.resolve(basePath, configPath) : path.join(basePath, "ui5.yaml");
let fileContent;
try {
fileContent = readFileSync(filePath);
Expand Down
14 changes: 14 additions & 0 deletions test/unit/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ test("UI5 Middleware / Proxy configuration: Should setup UI5 tooling middleware
t.deepEqual(setupUI5Server.lastCall.args, [{basePath: "", configPath: undefined}]);
});

test("ui5.yaml: should be configurable when autoDetectType",
async (t) => {
const {framework, logger, readFileSyncStub, sinon} = t.context;
const autoDetectTypeSpy = sinon.spy(framework, "autoDetectType");
const mockUI5YamlPath = "../ui5/yaml/ui5-custom.yaml";

framework.exists = () => true;
framework.init({config: {ui5: {configPath: mockUI5YamlPath}, basePath: "/alternative/app"}, logger});

t.true(autoDetectTypeSpy.calledOnce, "autoDetectType is called");
t.deepEqual(readFileSyncStub.lastCall.args, [path.resolve("/alternative/app", mockUI5YamlPath)],
"Custom ui5.yaml is provided");
});

// Sad path
test("UI5 Middleware / Proxy configuration: Should throw if ui5.yaml is missing and no url is configured",
async (t) => {
Expand Down

0 comments on commit 92847bd

Please sign in to comment.