Modernizr/grunt-modernizr

download source file modernizr-latest.js does not handle gzip response well

Closed this issue · 1 comments

Hello there, i am not a regular JS user but now i have to manage a grunt based project. and from time to time, when i run the grunt modernizr command, i encounter some error like

>> Generating a custom Modernizr build
>> Uglifying
Fatal error: Unexpected character ''

i checked down and found the modernizr-latest.js file in the cache folder (which is ./node_modules/grunt-modernizr/lib/cache in my case) are actually a binary file instead of a js file, which caused the uglify pipeline failed.

then i found that the default URL for modernizr-latest.js is http://modernizr.com/downloads/modernizr-latest.js, which has a 'content-encoding': 'gzip', header field. So it is clear that the file was not decompressed before grunt saved it into file system.

I have checked the request library, but the sample code use a different GET pattern compare to what's inside this repo, and the solution cannot be easily applied.

so my last choice is to modify the request.get by adding a header asking for unzipped response

headers: {
  'Accept-Encoding': 'identity'
},

which works fine with me now. but again, this doesn't looks cool and i would suggest a revised get version and use .on('data', function(data) instead of directly binding the response to the callback.

Hey @pankeshang!

sorry you never got a response :[.
its no longer downloading files, so this is no longer an issue