sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

stream option is not working #86

Closed seymen closed 3 years ago

seymen commented 7 years ago

Issuehunt badges

Hi,

I cannot get streaming output working. Here is what I am trying:

var through = require('through2');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;

var a = function() {
    return through.obj(function(zip, enc, cb) {
        console.log(zip);

        if (zip.isBuffer()) {
            cb(new PluginError('PLUGIN_NAME', 'Buffer is not supported as input to import operation'));
            return;
        }

        return cb(null, zip);
    });
};

gulp.task('test', function() {
    return gulp.src(['./apiproxy/**'], {base: '.'})
        .pipe(zip('test.zip', {buffer: false}))
        .pipe(a());
});

This basically sources a directory in, zips and pipes the output to a function called a(). In this function I am just asserting whether zip is buffer or not.

I am getting this output in console:

[15:40:33] Using gulpfile ~/projects/pers/gulp-apigee/examples/simple-proxy/gulpfile.js
[15:40:33] Starting 'test'...
<File "test.zip" <Buffer 50 4b 03 04 14 00 00 08 00 00 5d 7d 3f 4a 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 61 70 69 70 72 6f 78 79 2f 50 4b 03 04 14 00 00 08 08 00 5d ... >>
[15:40:33] 'test' errored after 32 ms
[15:40:33] Error in plugin 'PLUGIN_NAME'
Message:
    Buffer is not supported as input to import operation

Possible to help? Perhaps I am doing something wrong.

Cheers


IssueHunt Summary #### [gpoole gpoole](https://issuehunt.io/u/gpoole) has been rewarded. ### Backers (Total: $20.00) - [issuehunt issuehunt](https://issuehunt.io/u/issuehunt) ($20.00) ### Submitted pull Requests - [#118 Add support for streaming output with option](https://issuehunt.io/r/sindresorhus/gulp-zip/pull/118) --- ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/sindresorhus/gulp-zip/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds.
sindresorhus commented 7 years ago

You need to pass buffer: false to gulp.src, not this plugin.

seymen commented 7 years ago

thanks @sindresorhus - I guess when you put "supports streaming mode" in readme, you meant it supports stream as input.

I am still getting buffer as output from zip. Does this plugin support outputting stream instead of buffer? I am trying to pipe the output of zip to another write stream.

IssueHuntBot commented 5 years ago

@issuehunt has funded $20.00 to this issue.


sindresorhus commented 3 years ago

@gpoole Your PR fixes this, right?

gpoole commented 3 years ago

Yes it should fix this issue.

-------- Original Message -------- On 10 Mar 2021, 6:10 pm, Sindre Sorhus wrote:

@gpoole Your PR fixes this, right?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

issuehunt-oss[bot] commented 3 years ago

@sindresorhus has rewarded $18.00 to @gpoole. See it on IssueHunt

gpoole commented 3 years ago

Oh thanks for that @sindresorhus, appreciate it!