fix: try and catch for encoding

This commit is contained in:
TresAbhi committed 2023-06-02 01:50:18 +00:00
1 parent f4b20611d5
commit 2c8ae40ff8
5 files changed
+17 -19

No files matched your search

+12 -9
View File
@@ -1,5 +1,4 @@
import { WargamingResponse } from '../../types/wargamingResponse.js';
import isDev from '../process/isDev.js';
import URLToBase64 from '../ui/URLToBase64.js';
/*
@@ -58,12 +57,16 @@ export const TANK_IDS = Object.keys(tankopedia).map((id) => Number(id));
export const TANKS = TANK_IDS.map((id) => tankopedia[id]);
export const TANK_NAMES = TANKS.map((tank) => tank.name);
if (!isDev()) {
console.log('Encoding tank images...');
await Promise.all(
Object.entries(tankopedia).map(async ([, tank]) => {
console.log('Encoding tank images...');
await Promise.all(
Object.entries(tankopedia).map(async ([, tank]) => {
try {
tank.images.normal = await URLToBase64(tank.images.normal);
}),
);
console.log('Encoded tank images');
}
} catch (error) {
console.warn(
`Failed to encode tank image for ${tank.images.normal}: ${error}`,
);
}
}),
);
console.log('Encoded tank images');