fixed ADR file path in UrlResolver

Signed-off-by: Deepankumar Loganathan <deepan0433@gmail.com>
This commit is contained in:
Deepankumar Loganathan
2024-02-20 22:18:12 +01:00
parent 533563474d
commit 2e925ed076
3 changed files with 12 additions and 14 deletions
+1
View File
@@ -25,6 +25,7 @@ export const ANNOTATION_ADR_LOCATION = 'backstage.io/adr-location';
export const getAdrLocationUrl: (
entity: Entity,
scmIntegration: ScmIntegrationRegistry,
adrFilePath?: String,
) => string;
// @public
+8
View File
@@ -57,11 +57,19 @@ export const isAdrAvailable = (entity: Entity) =>
export const getAdrLocationUrl = (
entity: Entity,
scmIntegration: ScmIntegrationRegistry,
adrFilePath?: String,
) => {
if (!isAdrAvailable(entity)) {
throw new Error(`Missing ADR annotation: ${ANNOTATION_ADR_LOCATION}`);
}
if (adrFilePath) {
return scmIntegration.resolveUrl({
url: `${getAdrLocationDir(entity)!.replace(/\/$/, '')}/${adrFilePath}`,
base: getEntitySourceLocation(entity).target,
});
}
return scmIntegration.resolveUrl({
url: getAdrLocationDir(entity)!,
base: getEntitySourceLocation(entity).target,