From 7c1d06e02383d8ed400b5be09130de5983255975 Mon Sep 17 00:00:00 2001 From: yashpalgoyal1304 Date: Sun, 27 Nov 2022 02:06:01 +0530 Subject: [PATCH] Resolve scoping issue to get values of probeResult --- .github/workflows/image-minimizer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/image-minimizer.js b/.github/workflows/image-minimizer.js index fa9706faa..f4f132a72 100644 --- a/.github/workflows/image-minimizer.js +++ b/.github/workflows/image-minimizer.js @@ -55,6 +55,7 @@ module.exports = async ({github, context}) => { return match; } + let probeAspectRatio = 0; let shouldModify = false; try { console.log(`Probing ${g2}`); @@ -76,7 +77,8 @@ module.exports = async ({github, context}) => { } console.log(`Probing resulted in ${probeResult.width}x${probeResult.height}px`); - shouldModify = probeResult.height > IMG_MAX_HEIGHT_PX && (probeResult.width / probeResult.height) < MIN_ASPECT_RATIO; + probeAspectRatio = probeResult.width / probeResult.height; + shouldModify = probeResult.height > IMG_MAX_HEIGHT_PX && probeAspectRatio < MIN_ASPECT_RATIO; } catch(e) { console.log('Probing failed:', e); // Immediately abort @@ -86,7 +88,7 @@ module.exports = async ({github, context}) => { if (shouldModify) { wasMatchModified = true; console.log(`Modifying match '${match}'`); - return `${g1}`; + return `${g1}`; } console.log(`Match '${match}' is ok/will not be modified`);