reshape / minify

a reshape plugin to minify html output
Other
5 stars 3 forks source link

SVGO Errors are slient #27

Open hhsnopek opened 6 years ago

hhsnopek commented 6 years ago

Problem

During the investigation of #26, I discovered all the errors from svgo are silent.

Cause

Missing error handler when receiving the svgo results, lib/modules/minifySvg.js#L9

hhsnopek commented 6 years ago

I can pull request the solution in a short bit, for now I'm dropping the solution here:

svgo.optimize(rendered, ({ error, data }) => {
  if (error) reject(new Error(error))
  resolve(reshapeParser(data, ctx))
})

Backwards compatible node solution:

svgo.optimize(rendered, (res) => {
  if (res.error) reject(new Error(res.error))
  resolve(reshapeParser(res.data, ctx))
})

Edit: added backward compatible solution