TypeError when creating a zip file using gulp -vinyl-zip

I am trying to use Gulp to create a zip file for a Mac application containing symbolic links. I use gulp-vinyl-zip to get around the lack of symlink support in outputdest

var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');

gulp.task('default', function () {
    return gulp.src('tmp/Application.app/**/*')
        .pipe(zip.dest('releases/Application.zip'));
});

But I get the following error:

buffer.js:84
    throw new TypeError('must start with number, buffer, array or    string');
          ^
TypeError: must start with number, buffer, array or string
    at fromObject (buffer.js:84:11)
    at new Buffer (buffer.js:52:3)
    at DestroyableTransform.through.obj.stream.push.File.path [as _transform] (/opt/ygor/client/node_modules/gulp-vinyl-zip/lib/zip/index.js:24:21)
    at DestroyableTransform.Transform._read (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at DestroyableTransform._transform (/opt/ygor/client/node_modules/gulp-vinyl-zip/lib/dest/index.js:13:9)
    at DestroyableTransform.Transform._read (/opt/ygor/client/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)

In search of a solution, I thought it might require buffering rather than streaming vinyl file files, so I tried adding a vinyl buffer to the pipeline:

var gulp = require('gulp');
var zip = require('gulp-vinyl-zip');
var buffer = require('vinyl-buffer');

gulp.task('default', function () {
    return gulp.src('tmp/Application.app/**/*')
        .pipe(buffer())
        .pipe(zip.dest('releases/Application.zip'));
});

But I still get the same error message. Being new to Gulp, I think I am missing something fundamental. Any ideas?

+4
source share
1 answer

You can use the os built-in zip command:

gulp.task('default', function(cb) {
    require('child_process').exec('zip --symlinks -r ../releases/Application.zip Application.app', {
        cwd: 'tmp'
    }, function(err, stdout, stderr) {
        err ? console.err(stderr) : console.log(stdout);
        cb(err);
    });
});
0
source

All Articles