Josiah / gulp-cachebust

Generates checksums and renames references to files, useful for cachebusting
30 stars 11 forks source link

Added unit tests for simple methods. #18

Closed kjarnet closed 8 years ago

kjarnet commented 8 years ago

Thanks for this awesome easy-to-use cachbusting plugin! I found that the hash generated for a browserify-bundled run through vinyl-source always was the same, and traced it to your hash-generating method always yielding the same hash for stream-based files (working fine for buffer-based files). I've made a unit test demonstrating the problem, and also wrote some quick tests for some of the other methods, as I believe having better test coverage would make it easier for others to contribute to the project (and also trust in it). I haven't done much research on how to correct the issue, as for me, a workaround of piping the stream through gulp-buffer was good enough, but my first thought is you could use the hash of the content instead of the file-object itself. Anyway, I hope you can find this useful.

Josiah commented 8 years ago

Happy with this (except for the console.log statements), update and I'll merge.

kjarnet commented 8 years ago

Done. Are you planning on doing something with the checksum-for-streams-bug I mentioned? What do you think about the solution I suggested - hashing the content instead of the file-object - does it sound like a good approach? Do you want me to give it a try and submit another pull-request?

Josiah commented 8 years ago

Hashing the content is defintately the right approach, I'd suggest using the Vinyl file.pipe() method. A PR would be welcome :)