Xulai / broccoli-imagemin

Use imagemin in your broccoli build pipeline
ISC License
7 stars 2 forks source link

Fix pathnames handling #3

Closed eploko closed 9 years ago

eploko commented 9 years ago

Tried to use the plugin today and stumbled upon the fact it used broccoli tree objects as a string. That I believe was okay in the old days, but now it leads to bailing out along the lines of:

[broccoli-debug] [TreeMerger tree] Error: ENOENT, no such file or directory './[object Object]/images/logo.svg'
File: images/logo.svg
Error: ENOENT, no such file or directory './[object Object]/images/logo.svg'
  at Object.fs.statSync (fs.js:695:18)
  at imageminFilter.processString (.../node_modules/broccoli-imagemin/index.js:57:17)
  at imageminFilter.processFile (.../node_modules/broccoli-imagemin/index.js:89:31)
...

The PR fixes this by propagating the srcDir variable from the processFile method into the processString call. Plus, the file paths are now constructed with path.join(...) calls, which is safer than concatenating strings.

Hope this helps and you would merge it. Cheers. :)

Xulai commented 9 years ago

Thank you for the help. Merged.

Xulai commented 9 years ago

Published on npm as v0.2.0

eploko commented 9 years ago

Super! Thanks. :)