Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Consider configPath when autoDetectType #617

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ export default class Framework {
if (this.config.ui5.type) {
return;
}
const filePath = path.join(this.config.basePath, "ui5.yaml");
const filePath = this.config.ui5.configPath ?
path.resolve(this.config.ui5.configPath) : path.join(this.config.basePath, "ui5.yaml");
d3xter666 marked this conversation as resolved.
Show resolved Hide resolved
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 = "/alternative/ui5/yaml/ui5-custom.yaml";

framework.exists = () => true;
framework.init({config: {ui5: {configPath: mockUI5YamlPath}}, logger});

t.true(autoDetectTypeSpy.calledOnce, "autoDetectType is called");
t.deepEqual(readFileSyncStub.lastCall.args, [path.resolve(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
Loading