6c5a5256c7
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>
26 lines
550 B
JavaScript
26 lines
550 B
JavaScript
import { optimize } from "svgo";
|
|
import fs from "fs";
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
if (args.length === 0) {
|
|
console.error("Error: No input file");
|
|
console.log("Usage: svgo <input.svg> [output.svg]");
|
|
process.exit(1);
|
|
}
|
|
|
|
const [input, output = input] = args;
|
|
|
|
if (!fs.existsSync(input)) {
|
|
console.error("Error: File not found:", input);
|
|
process.exit(2);
|
|
}
|
|
|
|
const svg = fs.readFileSync(input, "utf8");
|
|
|
|
const result = optimize(svg, { multipass: true });
|
|
|
|
fs.writeFileSync(output, result.data);
|
|
|
|
console.log("✔ Optimized:", input);
|