Skip to content

Commit 0c8a55a

Browse files
nurikknurikk-sa
andauthored
Allow 512x512 images (Koenkk#2525)
* Allow 512x512 images * More verbose output --------- Co-authored-by: Ainur Timerbaev <[email protected]>
1 parent c96f573 commit 0c8a55a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docgen/tests/check-device-image-size.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ import * as path from "path";
66

77
const sizeOfP = promisify(sizeOf);
88
const ignore = ['.DS_Store'];
9-
9+
const allowedDimensions = ['150x150', '512x512'];
1010
export async function checkDeviceImageSize() {
11-
console.log('* Test if device images has 150x150px dimensions...');
12-
const invalid = [];
11+
console.log(`* Test if device images has ${allowedDimensions.join(' or ')} dimensions...`);
12+
const invalid = {};
1313
const images = (await fsp.readdir(imageBaseDir)).filter((f) => !ignore.includes(f));
1414
await Promise.all(images.map(async img => {
1515
const dimensions = await sizeOfP(path.resolve(imageBaseDir, img));
16-
if (dimensions.width != 150 || dimensions.height != 150) {
17-
invalid.push(img);
16+
const size = `${dimensions.width}x${dimensions.height}`;
17+
if (!allowedDimensions.includes(size)) {
18+
invalid[img] = size;
1819
}
1920
}));
2021

21-
if(invalid.length) {
22-
throw invalid.reduce((res, d) => res += `Image ${ d } does not have 150x150px\n`, "");
22+
if(Object.keys(invalid).length) {
23+
throw Object.entries(invalid).reduce((res, current_image_size_pair) => res += `Image ${ current_image_size_pair[0] } does not have ${allowedDimensions.join(' or ')} (size: ${current_image_size_pair[1]})\n`, "");
2324
}
2425
}

0 commit comments

Comments
 (0)