twolfson / grunt-zip

Zip and unzip files via a grunt plugin
MIT License
87 stars 19 forks source link

Windows - Makes huge zip files #16

Closed roytruelove closed 10 years ago

roytruelove commented 11 years ago

Node v 0.10.13 grunt-zip 0.9.2

Plugin creates a 16meg file, but when compressed (and before compression), the size is about 500k.

Config:

zip:
    dist:
        expand: true
        cwd: 'bower'
        src: ['**/*.*']
        dest: 'target/dist/bower.zip'
twolfson commented 11 years ago

Could you elaborate more? What size are the files that you are zipping? What do you mean by compression?

roytruelove commented 11 years ago

The full size of the 'bower' dir is about 500k, but the final zip is 16megs. When I unzip that 16m file, the result is only 500k. I've actually moved to grunt-contrib-compress for now since it's officially maintained by the grunt guys.

twolfson commented 11 years ago

Would you mind telling me what projects are in your bower directory so I can properly fix this?

roytruelove commented 11 years ago

They're mostly custom (it's proprietary unfortunately, so I can't send them to you.) There are some small .png files and other than that, text files (js, html, css, etc)

twolfson commented 11 years ago

Alright, thanks.

Ludevik commented 10 years ago

Hi, i have the same problem. I have config like this:

zip:
    dist:
        cwd: 'dir'
        src: ['**/*.*']
        dest: 'target/dir.zip'

The 'dir' directory contains ~500kB of data (some images, html, js and css). The 'dir.zip' has around 60MB, but it contains only the files from the 'dir' directory. My whole project with all node_modules and all stuff has around 60 MB too, so it looks like the zip task is somehow using the root of my project to calculate the file size.

twolfson commented 10 years ago

The size is probably a coincidence. I will take another look at this within the next week.

twolfson commented 10 years ago

Okay, I have successfully reproduced the bug via https://gist.github.com/twolfson/8488728

It looks like grunt-zip is including .. in its zip which is causing this behavior.

twolfson commented 10 years ago

To reiterate: This has not Windows specific and is reproducable on Linux.

twolfson commented 10 years ago

Okay, so this is all confusion around the docs. cwd is used only to route found files. It does not adjust the src path that is used or where it searches.

In both cases, this means that it is finding all files specified in **/* which is all files in the directory of the Gruntfile.

@roytruelove your config can be corrected via

        cwd: 'bower'
        src: ['bower/**/*.*']

@Ludevik your config can be corrected via

        cwd: 'dir'
        src: ['dir/**/*.*']

I personally dislike the cwd since both sides can argue whether it should/should not adjust the path. Unfortuantely, this is the current implementation and it is in the API so it will not be changed.

Instead of either, it is preferred to use router.