Resolve the target for globbed file locations correctly

Signed-off-by: Dominik Henneke <dominik.henneke@sda-se.com>
This commit is contained in:
Dominik Henneke
2021-05-14 11:49:02 +02:00
parent 1cfef4244e
commit 1b8e28aed5
3 changed files with 17 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Resolve the `target` for glob `file` locations correctly
@@ -79,6 +79,14 @@ describe('FileReaderProcessor', () => {
expect(emit).toBeCalledTimes(2);
expect(emit.mock.calls[0][0].entity).toEqual({ kind: 'Component' });
expect(emit.mock.calls[0][0].location).toEqual({
type: 'file',
target: expect.stringMatching(/^[^*]*$/),
});
expect(emit.mock.calls[1][0].entity).toEqual({ kind: 'API' });
expect(emit.mock.calls[1][0].location).toEqual({
type: 'file',
target: expect.stringMatching(/^[^*]*$/),
});
});
});
@@ -41,7 +41,10 @@ export class FileReaderProcessor implements CatalogProcessor {
for (const fileMatch of fileMatches) {
const data = await fs.readFile(fileMatch);
for (const parseResult of parseEntityYaml(data, location)) {
for (const parseResult of parseEntityYaml(data, {
type: 'file',
target: fileMatch,
})) {
emit(parseResult);
}
}