sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

Utilize JSZip.file() to update data in exist zip file #45

Closed rickychien closed 9 years ago

rickychien commented 9 years ago

See also JSZip doc: https://stuk.github.io/jszip/documentation/api_jszip/file_data.html

As document mentioned, we should just update zip entry if the zip file does exist rather than recreate a new zip again, so that it could combine with gulp-changed to speed up our incremental build.

Try to open exist zip by var zip = new JSZip(filePath) at [1].

[1] https://github.com/sindresorhus/gulp-zip/blob/master/index.js#L17

sindresorhus commented 9 years ago

How can we update it? gulp-zip don't know where you put it with gulp.dest. Can you provide an example of how it would look like?

rickychien commented 9 years ago

I'm not familiar with how gulp works, so I don't really know why gulp-zip cannot know where is the zip =( Are there any way to calculate the final location of zip so that we can pass it into gulp-zip?

sindresorhus commented 9 years ago

Gulp plugins just works on a stream of in-memory file objects. They have no sense of the filesystem. You could potentially pass the same path to gulp-zip as you pass to gulp.dest, but I'm not interested in adding such thing to this plugin.

kevva commented 9 years ago

Nope, this wouldn't work. Only thing I can think of is adding a existing option that would take a path to a existing archive and use that.

rickychien commented 9 years ago

+1 for adding a { existing: 'path/to/target.zip' } option so that gulp-zip could repack existed files.

kevva commented 9 years ago

@sindresorhus, wdyt? It's a pretty weird option but might make sense since zip archives can get pretty heavy.

kevva commented 9 years ago

Unfortunately this is no longer possible since the switch to https://github.com/thejoshwolfe/yazl. On the other hand, yazl should show a lot of speed improvements.