This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/svgo_output/svgo.js

29 lines
595 B
JavaScript
Raw Normal View History

2021-07-23 02:36:56 +02:00
var fs = require('fs');
var execSync = require('child_process').execSync;
var argv = require('minimist')(process.argv.slice(2), {boolean: true});
var SVGOptimize = require('svgo');
var file = fs.readFileSync(argv.file, 'utf8');
var options = {};
var optionsKeys = Object.keys(argv).filter(function(key) {
return key !== 'file' && key !== '_';
});
options.plugins = optionsKeys.map(function(key) {
var obj = {};
obj[key] = argv[key];
return obj;
});
var svgo = new SVGOptimize(options);
svgo.optimize(file, function (result) {
process.stdout.write(result.data);
});