Skip to content

Commit

Permalink
fix(core): Make populator.populateCollections more robust to bad input
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Nov 3, 2021
1 parent c0d22ef commit 8189c1b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/core/src/data-import/providers/populator/populator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ export class Populator {
const parent = collectionDef.parentName && collectionMap.get(collectionDef.parentName);
const parentId = parent ? parent.id.toString() : undefined;
const { assets } = await this.assetImporter.getAssets(collectionDef.assetPaths || []);

let filters: ConfigurableOperationInput[] = [];
try {
filters = (collectionDef.filters || []).map(filter =>
this.processFilterDefinition(filter, allFacetValues),
);
} catch (e) {
// tslint:disable-next-line:no-console
console.log(e);
}
const collection = await this.collectionService.create(ctx, {
translations: [
{
Expand All @@ -122,9 +130,7 @@ export class Populator {
parentId,
assetIds: assets.map(a => a.id.toString()),
featuredAssetId: assets.length ? assets[0].id.toString() : undefined,
filters: (collectionDef.filters || []).map(filter =>
this.processFilterDefinition(filter, allFacetValues),
),
filters,
});
collectionMap.set(collectionDef.name, collection);
}
Expand Down

0 comments on commit 8189c1b

Please sign in to comment.