sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

empty metadataPath error #50

Closed adam-lynch closed 9 years ago

adam-lynch commented 9 years ago

I was trying to confirm that #38 is fixed but I got this:

/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/yazl/index.js:230
  if (metadataPath === "") throw new Error("empty metadataPath");
                                 ^
Error: empty metadataPath
  at validateMetadataPath (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/yazl/index.js:230:34)
  at ZipFile.addBuffer (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/yazl/index.js:61:18)
  at DestroyableTransform.through.obj.zip.end.zip.outputStream.pipe.concatStream.push.gutil.File.cwd [as _transform] (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/index.js:33:7)
  at DestroyableTransform.Transform._read (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
  at writeOrBuffer (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
  at DestroyableTransform.Writable.write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
  at write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.EventEmitter.emit (events.js:92:17)
  at emitReadable_ (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at DestroyableTransform.noop [as _transform] (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/through2.js:26:3)
  at DestroyableTransform.Transform._read (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
  at writeOrBuffer (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
  at DestroyableTransform.Writable.write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
  at write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.EventEmitter.emit (events.js:92:17)
  at emitReadable_ (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at readDir (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/lib/src/getContents/readDir.js:5:3)
  at DestroyableTransform._transform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/lib/src/getContents/index.js:13:14)
  at DestroyableTransform.Transform._read (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
  at writeOrBuffer (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
  at DestroyableTransform.Writable.write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
  at write (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at DestroyableTransform.EventEmitter.emit (events.js:92:17)
  at emitReadable_ (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
  at DestroyableTransform.Readable.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
  at DestroyableTransform.Transform.push (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
  at afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
  at TransformState.afterTransform (/Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
  at /Users/adam/Code/GitHub/teamwork-chat-client/node_modules/gulp/node_modules/vinyl-fs/lib/src/getStats.js:15:5
  at Object.oncomplete (evalmachine.<anonymous>:107:15)

cc @kevva

kevva commented 9 years ago

Hmm, it seems like you have files without file.path.

adam-lynch commented 9 years ago

Hmm don't see how that could be;

    gulp.src source
        .pipe $.zip generateZipName(...)
        .pipe gulp.dest paths.dist.root
        .pipe $.size {showFiles: true}
        .on 'finish', done
    return
kevva commented 9 years ago

Well, the error suggests that. The metadataPath is pathname on this and this line. But yeah, it sounds weird.

adam-lynch commented 9 years ago

I logged the file after the gulp.src;

{ dev: 16777218,
  mode: 16877,
  nlink: 3,
  uid: 502,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 42474491,
  size: 102,
  blocks: 0,
  atime: Tue Mar 31 2015 17:47:18 GMT+0100 (IST),
  mtime: Tue Mar 31 2015 17:47:17 GMT+0100 (IST),
  ctime: Tue Mar 31 2015 17:47:17 GMT+0100 (IST) }

The glob passed to gulp.src is ./dist/TeamworkChat/osx32/**/**.

adam-lynch commented 9 years ago

That was on OSX (Mavericks) where ./dist/TeamworkChat/osx32 contained a single .app.

I've gotten the same error on Windows 8. I use the same wrapper function so the call is the same except on Windows the glob is ./dist/TeamworkChat/win32/**/** and ./dist/TeamworkChat/win32/ contains the following:

image

kevva commented 9 years ago

Do you mind creating a repo with your stuff so I can test?

adam-lynch commented 9 years ago

@kevva here ya go: https://github.com/adam-lynch/gulp-zip-metadata-error

DavidRogers commented 9 years ago

I am getting the same exact error on Window 8... my gruntfile.js:

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

var paths = {
    src: ['images/**', 'lib/**', 'index.html', 'main.js']
};

gulp.task('default', function () {
    return gulp.src(paths.src)
        .pipe(zip('MyZippedFile.zip'))
        .pipe(gulp.dest('../'));
});

I played around a little and found that it will only work if I specify a single file such as 'index.html' but if I used a file glob it will fail with this error.

EDIT: This seems to be broken only in v3.0.0, I ran the same code with v2.0.3 and it works fine.

kevva commented 9 years ago

@adam-lynch, works fine for me using this:

gulp.task('default', function () {
    return gulp.src('dist/TeamworkChat/win32/**/*')
        .pipe(zip('archive.zip'))
        .pipe(gulp.dest('dist'));
});

Because you are using globs that ends with ** some directories doesn't have file.relative set. Best way to avoid this issue is to use **/* or just *.

adam-lynch commented 9 years ago

Thanks