Skip to content

Commit

Permalink
Update cli tool
Browse files Browse the repository at this point in the history
niwinz committed Oct 22, 2024
1 parent de14bf2 commit 581e40b
Showing 2 changed files with 67 additions and 4 deletions.
56 changes: 56 additions & 0 deletions sample.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions src/svgoCli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const fs = require("fs");
const process = require("process");
const svgo = require("./svgo.js");
const input = fs.readFileSync(0, 'utf-8');
const output = svgo.optimize(input, svgo.defaultOptions);
process.stdout.write(output);
process.exit(0);

try {
const input = fs.readFileSync(0, {encoding: 'utf-8'});
const output = svgo.optimize(input, svgo.defaultOptions);
fs.writeFileSync(1, output, {encoding: 'utf-8', flush: true});
process.exit(0);
} catch (cause) {
console.error(cause);
process.exit(1);
}

0 comments on commit 581e40b

Please sign in to comment.