sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

Passing object as params #27

Closed kvervo closed 10 years ago

kvervo commented 10 years ago

Hi!

I would like to propose to change the way params gets passed.

The problem is that when creating dynamically the filename value (using async tasks or functions) the filename is not updated.

For example (maybe to raw):

module.exports = function () {
    var filename = 'file_';
    return gulp.src(path)
        .pipe(through.obj(function (file, enc, cb) {
            exec("git rev-parse --abbrev-ref HEAD", {cwd: file.cwd}, function (err, stdout, stderr) {
                filename = filename + stdout;
                this.push(file);
                cb();
            }.bind(this));
        }))
        .pipe(zip(filename + '.zip'))
}

The output zip will always have the following name: file_.zip

Perhaps there is an easy way to solve this, but haven't found it.

I would propose to add the possibility to pass functions as params, as here: https://github.com/wearefractal/vinyl-fs/commit/583d30efd72267b59752f98a920541b1cfadb31c