Skip to content

Commit 5fb525e

Browse files
committed
fix(build.js): handle promise in icon build
1 parent 890e38e commit 5fb525e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

build.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,23 @@ const writeIconComponents = async (buildPath, components) => {
6565
}
6666

6767
const buildIconBodyList = (svgPath, svgList) => {
68-
return svgList.map(svg => ({
68+
return Promise.all(svgList.map(async svg => ({
6969
name: toPascalCase(svg).slice(0, -4),
70-
path: async () => {
70+
path: await (async () => {
7171
const svgFile = await readFileAsync(path.join(svgPath, svg))
7272
const matches = /\sd="(.*)"/.exec(svgFile)
7373

7474
return matches ? matches[0] : undefined
75-
}
76-
}))
75+
})()
76+
})))
7777
}
7878

7979
fs.readdir(SVG_PATH, async (err, svgList) => {
8080
if (err) {
8181
throw new Error(err)
8282
}
8383

84-
const svgBodyList = buildIconBodyList(SVG_PATH, svgList)
84+
const svgBodyList = await buildIconBodyList(SVG_PATH, svgList)
8585
const iconComponents = await buildIconComponents(TPL_PATH, svgBodyList)
8686
await writeIconComponents(BUILD_PATH, iconComponents)
8787
await copyPackage(PKG_FILE, path.resolve(DIST_PATH, 'package.json'))

0 commit comments

Comments
 (0)