首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用gulp-vinyl zip创建压缩文件时的TypeError

使用gulp-vinyl zip创建压缩文件时的TypeError
EN

Stack Overflow用户
提问于 2015-05-29 12:22:08
回答 1查看 306关注 0票数 4

我正在尝试使用Gulp创建一个包含符号链接的Mac应用程序的zip文件。我正在使用gulp-vinyl-zip来绕过lack of symlink support in the output of dest

代码语言:javascript
复制
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'));
});

但我得到以下错误:

代码语言:javascript
复制
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)

在寻找解决方案时,我认为可能需要缓冲而不是流式传输乙烯基文件对象,所以我尝试在管道中添加乙烯基缓冲层:

代码语言:javascript
复制
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'));
});

但我仍然收到相同的错误消息。作为Gulp的新手,我想我错过了一些有趣的东西。有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2015-11-02 02:30:51

您可能希望使用os内置的zip命令:

代码语言:javascript
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30521106

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档