mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
Remove await within loop
This commit is contained in:
parent
7feaa479c0
commit
8d766ac504
@ -51,12 +51,20 @@ function addThemesToConfig(bundle, manifestLocations, defaultThemes) {
|
|||||||
*/
|
*/
|
||||||
async function generateIconSourceMap(icons, manifestLocation) {
|
async function generateIconSourceMap(icons, manifestLocation) {
|
||||||
const sources = {};
|
const sources = {};
|
||||||
|
const fileNames = [];
|
||||||
|
const promises = [];
|
||||||
const fs = require("fs").promises;
|
const fs = require("fs").promises;
|
||||||
for (const icon of Object.values(icons)) {
|
for (const icon of Object.values(icons)) {
|
||||||
const [location] = icon.split("?");
|
const [location] = icon.split("?");
|
||||||
const resolvedLocation = path.resolve(__dirname, "../../", manifestLocation, location);
|
const resolvedLocation = path.resolve(__dirname, "../../", manifestLocation, location);
|
||||||
const iconData = await fs.readFile(resolvedLocation);
|
const iconData = fs.readFile(resolvedLocation);
|
||||||
const svgString = iconData.toString();
|
promises.push(iconData);
|
||||||
|
const fileName = path.basename(resolvedLocation);
|
||||||
|
fileNames.push(fileName);
|
||||||
|
}
|
||||||
|
const results = await Promise.all(promises);
|
||||||
|
for (let i = 0; i < results.length; ++i) {
|
||||||
|
const svgString = results[i].toString();
|
||||||
const result = optimize(svgString, {
|
const result = optimize(svgString, {
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
@ -68,8 +76,7 @@ async function generateIconSourceMap(icons, manifestLocation) {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
const optimizedSvgString = result.data;
|
const optimizedSvgString = result.data;
|
||||||
const fileName = path.basename(resolvedLocation);
|
sources[fileNames[i]] = optimizedSvgString;
|
||||||
sources[fileName] = optimizedSvgString;
|
|
||||||
}
|
}
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user