schnee effeckt und fehler Korektur
This commit is contained in:
53
node_modules/imagemin-svgo/index.js
generated
vendored
53
node_modules/imagemin-svgo/index.js
generated
vendored
@@ -1,47 +1,18 @@
|
||||
'use strict';
|
||||
const isSvg = require('is-svg');
|
||||
const {optimize} = require('svgo');
|
||||
|
||||
var isSvg = require('is-svg');
|
||||
var SVGO = require('svgo');
|
||||
var through = require('through2');
|
||||
module.exports = options => async buffer => {
|
||||
options = {multipass: true, ...options};
|
||||
|
||||
module.exports = function (opts) {
|
||||
opts = opts || {};
|
||||
if (!isSvg(buffer)) {
|
||||
return Promise.resolve(buffer);
|
||||
}
|
||||
|
||||
return through.ctor({objectMode: true}, function (file, enc, cb) {
|
||||
if (file.isNull()) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
if (Buffer.isBuffer(buffer)) {
|
||||
buffer = buffer.toString();
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
cb(new Error('Streaming is not supported'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSvg(file.contents)) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var svgo = new SVGO(opts);
|
||||
|
||||
svgo.optimize(file.contents.toString('utf8'), function (res) {
|
||||
if (!res.data || !res.data.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
res.data = res.data.replace(/&(?!amp;)/g, '&');
|
||||
res.data = new Buffer(res.data);
|
||||
|
||||
file.contents = res.data;
|
||||
});
|
||||
} catch (err) {
|
||||
err.fileName = file.path;
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, file);
|
||||
});
|
||||
const {data} = optimize(buffer, options);
|
||||
return Buffer.from(data);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user