mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 12:14:24 +01:00
fix(icon_pack): listing definitions even if parsing fails
This commit is contained in:
parent
2c4ac4ba30
commit
a26923cc6d
@ -174,4 +174,21 @@ describe("Icon registery", () => {
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores incorrect manifest", () => {
|
||||
const iconPack = processIconPack(buildNote({
|
||||
type: "text",
|
||||
content: JSON.stringify({
|
||||
name: "Boxicons v2",
|
||||
prefix: "bx",
|
||||
icons: {
|
||||
"bx-ball": "\ue9c2",
|
||||
"bxs-party": "\uec92"
|
||||
}
|
||||
}),
|
||||
attachments: [ defaultAttachment ]
|
||||
}));
|
||||
const registry = generateIconRegistry([ iconPack! ]);
|
||||
expect(registry.sources).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@ -43,13 +43,18 @@ export function generateIconRegistry(iconPacks: ProcessResult[]): IconRegistry {
|
||||
const sources: IconRegistry["sources"] = [];
|
||||
|
||||
for (const { manifest } of iconPacks) {
|
||||
const icons: IconRegistry["sources"][number]["icons"] = Object.entries(manifest.icons)
|
||||
.map(( [id, { terms }] ) => {
|
||||
if (!id || !terms) return null;
|
||||
return { id, terms };
|
||||
})
|
||||
.filter(Boolean) as IconRegistry["sources"][number]["icons"];
|
||||
if (!icons.length) continue;
|
||||
|
||||
sources.push({
|
||||
prefix: manifest.prefix,
|
||||
name: manifest.name,
|
||||
icons: Object.entries(manifest.icons).map(( [id, { terms }] ) => ({
|
||||
id,
|
||||
terms
|
||||
}))
|
||||
icons
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user