Use local svgo.cmd wrapper binary

Switch SVG optimizer resolution from bin/svgo-cli.exe to bin/svgo.cmd.

Update unit tests to validate the new local binary path behavior.

Co-Authored-By: Abacus.AI CLI <agent@abacus.ai>
This commit is contained in:
2026-06-08 14:50:19 +02:00
parent 75059f829a
commit 6c5a5256c7
1054 changed files with 152359 additions and 7 deletions
+8 -5
View File
@@ -51,6 +51,7 @@ PROGRESS_BAR_LEN = 40
TEMP_PREFIX = "pptx_compress_"
DEFAULT_MIN_SAVINGS = "2%"
PNG_TO_JPEG_THRESHOLD_BYTES = 500 * 1024
SVGO_CLI_RELATIVE_PATH = Path("bin") / "svgo-client" / "svgo.cmd"
@dataclass
@@ -238,21 +239,23 @@ def compress_raster_image(
)
def get_svgo_executable_path() -> Path:
return Path(__file__).resolve().parent / SVGO_CLI_RELATIVE_PATH
def compress_svg_with_svgo(
original: Path,
out_dir: Path,
) -> Path | None:
if original.suffix.lower() not in VECTOR_EXT:
return None
npx_exe = which("npx")
if not npx_exe:
svgo_exe = get_svgo_executable_path()
if not svgo_exe.exists() or not svgo_exe.is_file():
return None
out_dir.mkdir(parents=True, exist_ok=True)
out_file = out_dir / original.name
cmd = [
npx_exe,
"--yes",
"svgo",
str(svgo_exe),
str(original),
"-o",
str(out_file),