Skip to content

Commit

Permalink
fix(build.js): handle promise in icon build
Browse files Browse the repository at this point in the history
  • Loading branch information
therufa committed Dec 16, 2017
1 parent 890e38e commit 5fb525e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ const writeIconComponents = async (buildPath, components) => {
}

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

return matches ? matches[0] : undefined
}
}))
})()
})))
}

fs.readdir(SVG_PATH, async (err, svgList) => {
if (err) {
throw new Error(err)
}

const svgBodyList = buildIconBodyList(SVG_PATH, svgList)
const svgBodyList = await buildIconBodyList(SVG_PATH, svgList)
const iconComponents = await buildIconComponents(TPL_PATH, svgBodyList)
await writeIconComponents(BUILD_PATH, iconComponents)
await copyPackage(PKG_FILE, path.resolve(DIST_PATH, 'package.json'))
Expand Down

0 comments on commit 5fb525e

Please sign in to comment.