diff --git a/CHANGELOG.md b/CHANGELOG.md index 71eecb830..ed12149fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### [ [>](https://github.com/svg/svgo/tree/v1.3.2) ] 1.3.2 / 30.10.2019 +* Fixed TypeError: Cannot set property 'multipassCount' of undefined + ### [ [>](https://github.com/svg/svgo/tree/v1.3.1) ] 1.3.1 / 29.10.2019 * Updated CSSO version to 4.0.2 fixing the issue with empty semicolons ";;" in styles (thanks to @strarsis and @lahmatiy). * `prefixIds` plugin now runs only once with `--multipass` option (by @strarsis). diff --git a/README.md b/README.md index 3b676e0ba..bce6c91a4 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ Arguments: * as a Sketch plugin - [svgo-compressor](https://github.com/BohemianCoding/svgo-compressor) * as macOS app - [Image Shrinker](https://image-shrinker.com) * as a Rollup plugin - [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo) +* as a Figma plugin - [Advanced SVG Export](https://www.figma.com/c/plugin/782713260363070260/Advanced-SVG-Export) ## Backers diff --git a/README.ru.md b/README.ru.md index 319e963ce..61fe57e21 100644 --- a/README.ru.md +++ b/README.ru.md @@ -197,6 +197,7 @@ $ [sudo] npm install -g svgo * как плагин для Sketch - [svgo-compressor](https://github.com/BohemianCoding/svgo-compressor) * в виде приложения macOS - [Image Shrinker](https://image-shrinker.com) * как плагин для Rollup - [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo) +* как плагин для Figma - [Advanced SVG Export](https://www.figma.com/c/plugin/782713260363070260/Advanced-SVG-Export) ## Лицензия и копирайты diff --git a/lib/svgo.js b/lib/svgo.js index 9ed8db37f..287604bfa 100644 --- a/lib/svgo.js +++ b/lib/svgo.js @@ -22,6 +22,9 @@ var SVGO = function(config) { }; SVGO.prototype.optimize = function(svgstr, info) { + info = info || {}; + info.multipassCount = 0; + return new Promise((resolve, reject) => { if (this.config.error) { reject(this.config.error); @@ -74,7 +77,7 @@ SVGO.prototype._optimizeOnce = function(svgstr, info, callback) { /** * The factory that creates a content item with the helper methods. * - * @param {Object} data which passed to jsAPI constructor + * @param {Object} data which is passed to jsAPI constructor * @returns {JSAPI} content item */ SVGO.prototype.createContentItem = function(data) { diff --git a/package-lock.json b/package-lock.json index a03fd67f8..b83f54d95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svgo", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 772f00e83..4f4f18267 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svgo", - "version": "1.3.1", + "version": "1.3.2", "description": "Nodejs-based tool for optimizing SVG vector graphics files", "keywords": [ "svgo", diff --git a/plugins/cleanupIDs.js b/plugins/cleanupIDs.js index 918474a04..71ffb5f93 100644 --- a/plugins/cleanupIDs.js +++ b/plugins/cleanupIDs.js @@ -58,15 +58,18 @@ exports.fn = function(data, params) { // quit if @@ -9,7 +9,7 @@ diff --git a/test/plugins/cleanupIDs.19.svg b/test/plugins/cleanupIDs.19.svg new file mode 100644 index 000000000..b961e21bf --- /dev/null +++ b/test/plugins/cleanupIDs.19.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + +@@@ + + + + + + + + + + + diff --git a/test/plugins/cleanupIDs.20.svg b/test/plugins/cleanupIDs.20.svg new file mode 100644 index 000000000..2fa086946 --- /dev/null +++ b/test/plugins/cleanupIDs.20.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + +@@@ + + + + + + + + + + + + + + + + + + + +@@@ + +{"prefix": "test__", "remove": "false"} diff --git a/test/plugins/convertPathData.04.svg b/test/plugins/convertPathData.04.svg index 0dae5fde3..c169d833a 100644 --- a/test/plugins/convertPathData.04.svg +++ b/test/plugins/convertPathData.04.svg @@ -5,6 +5,7 @@ + @@@ @@ -16,4 +17,5 @@ + diff --git a/test/plugins/prefixIds.10.svg b/test/plugins/prefixIds.10.svg new file mode 100644 index 000000000..7b4ce3188 --- /dev/null +++ b/test/plugins/prefixIds.10.svg @@ -0,0 +1,15 @@ + + + + + + + +@@@ + + + + + + + diff --git a/test/svgo/_index.js b/test/svgo/_index.js index 327c5de72..3d2cbcc75 100644 --- a/test/svgo/_index.js +++ b/test/svgo/_index.js @@ -41,6 +41,39 @@ describe('indentation', function() { }); +describe('invocation', function() { + + it('should optimize without an info object', function(done) { + + var filepath = PATH.resolve(__dirname, './test.svg'), + svgo; + + FS.readFile(filepath, 'utf8', function(err, data) { + if (err) { + throw err; + } + + var splitted = normalize(data).split(/\s*@@@\s*/), + orig = splitted[0], + should = splitted[1]; + + svgo = new SVGO({ + full : true, + plugins : [], + js2svg : { pretty: true, indent: 2 } + }); + + svgo.optimize(orig, undefined).then(function(result) { + normalize(result.data).should.be.equal(should); + done(); + }); + + }); + + }); + +}); + function normalize(file) { return file.trim().replace(regEOL, '\n'); }