Skip to content

Commit

Permalink
fix: add to backend array case
Browse files Browse the repository at this point in the history
  • Loading branch information
broksy committed Oct 10, 2024
1 parent df5dff0 commit 9a3a043
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/ui5-config/src/ui5config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,27 @@ export class UI5Config {
let backendNode;
const proxyMiddlewareYamlContent = this.findCustomMiddleware(fioriToolsProxy);
const proxyMiddlewareConfig = proxyMiddlewareYamlContent?.configuration as FioriToolsProxyConfig;
// Avoid adding duplicates by checking existing backend configs
// Add new entry to existing backend configurations in yaml
if (proxyMiddlewareConfig?.backend) {
// Avoid adding duplicates by checking existing backend configs
if (!proxyMiddlewareConfig.backend.find((existingBackend) => existingBackend.url === backend.url)) {
// Create new 'backend' node in yaml for middleware config keeping previous backend definitions
backendNode = this.document.createNode({
value: [...proxyMiddlewareConfig.backend, backend],
value: backend,
comments
});
const configuration = this.document.getMap({
start: proxyMiddleware as YAMLMap,
path: 'configuration'
});
const backendConfigs = this.document.getSequence({ start: configuration, path: 'backend' });
backendConfigs.add(backendNode);
}
} else {
// Create new 'backend' node in yaml for middleware config
backendNode = this.document.createNode({ value: [backend], comments });
}
if (backendNode) {
// Create a new 'backend' node in yaml for middleware config
backendNode = this.document.createNode({ value: backend, comments });
this.document
.getMap({ start: proxyMiddleware as YAMLMap, path: 'configuration' })
.set('backend', backendNode);
.set('backend', [backendNode]);
}
return this;
}
Expand Down

0 comments on commit 9a3a043

Please sign in to comment.