From ef3fbcf954c3f51ac33cd75bf7ee140a086e4f00 Mon Sep 17 00:00:00 2001 From: Niloth P <20315308+Niloth-p@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:02:58 +0530 Subject: [PATCH] optimize-svg: The --check flag does not modify files anymore. The `svgo` command needs to write to a file to process it. So, create and use a mktemp path, and delete it after the svgo command. --- tools/setup/optimize-svg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/setup/optimize-svg b/tools/setup/optimize-svg index 78ecebbe11..2fec28786d 100755 --- a/tools/setup/optimize-svg +++ b/tools/setup/optimize-svg @@ -46,7 +46,9 @@ PNPM="/usr/local/bin/pnpm" FILE_PATH="static/images/integrations/logos" if [ -n "$CHECK_UNOPTIMIZED" ]; then - RESULT=$("$PNPM" exec svgo -f "$FILE_PATH" | grep -o '\.[0-9]% = ' | wc -l) + TEMP_PATH=$(mktemp -d svgo_temp_XXXXXX) + RESULT=$("$PNPM" exec svgo -o "$TEMP_PATH" -f "$FILE_PATH" | grep -o '\.[0-9]% = ' | wc -l) + rm -rf "$TEMP_PATH" if [ "$RESULT" -ge 1 ]; then echo "ERROR: svgo detected unoptimized SVG file(s)." 1>&2 echo "Please run tools/setup/optimize-svg and commit the file changes to optimize them."