fix(configLoader): properly resolve targets into absolute paths

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2023-10-19 12:02:23 -04:00
parent 776d2c3fca
commit 22ca64f117
3 changed files with 16 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/config-loader': patch
---
Correctly resolve config targets into absolute paths
@@ -95,6 +95,14 @@ describe('ConfigSources', () => {
),
).toEqual([{ name: 'FileConfigSource', path: '/config.yaml' }]);
expect(
mergeSources(
ConfigSources.defaultForTargets({
targets: [{ type: 'path', target: 'config.yaml' }],
}),
),
).toEqual([{ name: 'FileConfigSource', path: resolvePath('config.yaml') }]);
const subFunc = async () => undefined;
expect(
mergeSources(
@@ -172,8 +180,8 @@ describe('ConfigSources', () => {
}),
),
).toEqual([
{ name: 'FileConfigSource', path: 'a.yaml' },
{ name: 'FileConfigSource', path: 'b.yaml' },
{ name: 'FileConfigSource', path: resolvePath('a.yaml') },
{ name: 'FileConfigSource', path: resolvePath('b.yaml') },
{ name: 'EnvConfigSource', env: { HOME: '/' } },
]);
});
@@ -161,7 +161,7 @@ export class ConfigSources {
}
return FileConfigSource.create({
watch: options.watch,
path: arg.target,
path: resolvePath(arg.target),
substitutionFunc: options.substitutionFunc,
});
});