Skip to content

Commit 62f5688

Browse files
committed
refactor: top level await
1 parent 397165b commit 62f5688

1 file changed

Lines changed: 20 additions & 27 deletions

File tree

scripts/generate-file-tree-sprite.ts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,23 @@ function buildSprite(
6969
return `<svg xmlns="http://www.w3.org/2000/svg" style="display:none">${symbols}</svg>\n`
7070
}
7171

72-
async function main() {
73-
const collections = await loadCollections()
74-
const iconNames = [
75-
...Object.values(EXTENSION_ICONS),
76-
...Object.values(FILENAME_ICONS),
77-
...Object.values(COMPOUND_EXTENSIONS),
78-
...Object.values(ADDITIONAL_ICONS),
79-
DEFAULT_ICON,
80-
]
81-
const grouped = groupByCollection(iconNames)
82-
const sprite = buildSprite(grouped, collections)
83-
await Promise.all([
84-
fs.mkdir(path.dirname(outputDevPath), { recursive: true }),
85-
fs.mkdir(path.dirname(outputStagePath), { recursive: true }),
86-
fs.mkdir(path.dirname(outputProdPath), { recursive: true }),
87-
])
88-
await Promise.all([
89-
fs.writeFile(outputDevPath, sprite, 'utf8'),
90-
fs.writeFile(outputStagePath, sprite, 'utf8'),
91-
fs.writeFile(outputProdPath, sprite, 'utf8'),
92-
])
93-
}
94-
95-
main().catch(error => {
96-
console.error(error)
97-
process.exitCode = 1
98-
})
72+
const collections = await loadCollections()
73+
const iconNames = [
74+
...Object.values(EXTENSION_ICONS),
75+
...Object.values(FILENAME_ICONS),
76+
...Object.values(COMPOUND_EXTENSIONS),
77+
...Object.values(ADDITIONAL_ICONS),
78+
DEFAULT_ICON,
79+
]
80+
const grouped = groupByCollection(iconNames)
81+
const sprite = buildSprite(grouped, collections)
82+
await Promise.all([
83+
fs.mkdir(path.dirname(outputDevPath), { recursive: true }),
84+
fs.mkdir(path.dirname(outputStagePath), { recursive: true }),
85+
fs.mkdir(path.dirname(outputProdPath), { recursive: true }),
86+
])
87+
await Promise.all([
88+
fs.writeFile(outputDevPath, sprite, 'utf8'),
89+
fs.writeFile(outputStagePath, sprite, 'utf8'),
90+
fs.writeFile(outputProdPath, sprite, 'utf8'),
91+
])

0 commit comments

Comments
 (0)