jstuckey / gulp-gzip

Gzip plugin for gulp.
MIT License
175 stars 17 forks source link

Some extension of plugin #4

Closed KyivJunta closed 10 years ago

KyivJunta commented 10 years ago

HI, just wanted to have control of what should be compressed depending on size and wanted to have an option to NOT append .gz extension (usually CDN can respond with correct headers independently of extension).

Result - 2 options can be passed to plugin:

Plugin handles Buffers and Streams.

Actually tried to make threshold option pretty handy - it can receive String (parsed by bytes, hard limited in 150), Number (exact size in bytes, hard limited in 150), Boolean (false - compress independently on size, true - resulting hard limit - 150).

Also replaced event-stream with through2 - reason is that ev built with Streams1 in mind and during extending of your plugin, I had couple of problems because of incapability of ev with Streams2.

Also rewritten tests - including originals with addition of test suit for extended capabilities. Now for testing you can use npm test/gulp. Also added as dev-dependency gulp with little zoo of plugins allowing to livecode while testing.

Also added example folder demonstrating few usage scenarios.

KyivJunta commented 10 years ago

If needed also can update README with some some examples and new features.

jstuckey commented 10 years ago

Great work! I will merge when I get a chance.

KyivJunta commented 10 years ago

Actually just pointed out that it needs some fixes with tests and utils module. I'l note you when its ready. BTW thanks for fast response!

KyivJunta commented 10 years ago

All done, ready for merging. BTW, when using main gulpfile.js for livecoding with testing, there is some bug with gulp-watch dependency - gaze, so test task can be runned multiple times.

KyivJunta commented 10 years ago

Its now ready to merge pr and update npm package.

jstuckey commented 10 years ago

I will merge this when I get a change. You essentially rewrote the entire plugin though, so I want to review it thoroughly rather than doing an auto-merge.

KyivJunta commented 10 years ago

Ok. I created temporary repo/npm gzip2. When (if) you will be ready, notify me and ill delete them.

jstuckey commented 10 years ago

Alright, I merged these changes, but I reorganized a little bit. I like to keep the main module code in index.js if it isn't too complicated. I also pulled out the threshold checking for stream mode and put it in util.js.

I really like your testing code. Good work. Thanks for the PR!