2015-05-29 154 views
4

我正在嘗試使用Gulp創建包含符號鏈接的Mac應用程序的zip文件。我使用gulp-vinyl-zip以繞過lack of symlink support in the output of dest創建zip文件時使用gulp-vinyl-zip創建TypeError

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')); 
}); 

,但我得到了以下錯誤:

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) 

尋找解決的辦法,我想這可能是緩衝,而不是流媒體文件的乙烯對象可能所以我試圖添加乙烯基緩衝區管道:

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的新手,我想我錯過了一些有趣的東西。有任何想法嗎?

回答

0

您可能需要使用內置拉鍊命令操作系統:

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); 
    }); 
});