Skip to content

Commit

Permalink
feat(figma-plugin): handle icon extract fail case
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwooseong committed Mar 13, 2024
1 parent 898f221 commit 11c49c5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/bezier-figma-plugin/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,25 @@ async function extractIcon() {

const svgs = await Promise.all(componentNodes.map((
async (node) => {
const svg = await node.exportAsync({ format: 'SVG_STRING' })
const id = node.name
return {
svg,
id,
try {
const svg = await node.exportAsync({ format: 'SVG_STRING' })
const id = node.name
return {
svg,
id,
}
} catch (e) {
/* eslint-disable no-console */
console.log(e)
console.log(node)
/* eslint-enable no-console */
return undefined
}
}
)))

const svgByName = svgs.reduce((acc, cur) => {
if (!cur?.id) { return acc }
acc[cur.id] = cur
return acc
}, {} as SvgByName)
Expand Down

0 comments on commit 11c49c5

Please sign in to comment.