ben-eb / gulp-svgmin

Minify SVG files with gulp.
MIT License
340 stars 35 forks source link

Fix bug #97

Closed corollari closed 4 years ago

corollari commented 4 years ago

Bug

This svg image will cause the following error when applied to gulp-svgmin:

/home/corollari/projects/neo-mon/node_modules/svgo/plugins/convertPathData.js:766
        if (data[i].toFixed(precision) != data[i]) {
                    ^

TypeError: Cannot read property 'toFixed' of undefined
    at strongRound (/home/corollari/projects/neo-mon/node_modules/svgo/plugins/convertPathData.js:766:21)
    at /home/corollari/projects/neo-mon/node_modules/svgo/plugins/convertPathData.js:424:17
    at Array.filter (<anonymous>)
    at filters (/home/corollari/projects/neo-mon/node_modules/svgo/plugins/convertPathData.js:272:17)
    at Object.exports.fn (/home/corollari/projects/neo-mon/node_modules/svgo/plugins/convertPathData.js:79:20)
    at /home/corollari/projects/neo-mon/node_modules/svgo/lib/svgo/plugins.js:59:45
    at Array.filter (<anonymous>)
    at monkeys (/home/corollari/projects/neo-mon/node_modules/svgo/lib/svgo/plugins.js:46:39)
    at /home/corollari/projects/neo-mon/node_modules/svgo/lib/svgo/plugins.js:66:17
    at Array.filter (<anonymous>)

Solution

As discovered in this issue the problem seems to stem from the svgo dependency, which I have updated to a problem-free version. I haven't updated it to the latest version as it seems the same issue has reappeared in later versions (I haven't tested it tho).

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 6aff57c4a9e757bb2bdd5cd265dceee881984128 on corollari:master into e5c2a75c4ec13717140437b6218e88bc5e3f6ab6 on ben-eb:master.

rejas commented 4 years ago

Thx for the PR @corollari but could you check why the travis builds fails?

corollari commented 4 years ago

Just fixed the travis build :+1:

madhaze commented 4 years ago

Did this ever make it into a release? it looks like svgo is still at 1.2.1 on 2.2.0 release.

rejas commented 4 years ago

You are right, this wasnt released yet. Just published v3.0.0 with this fix and other stuff. Enjoy!