Skip to content

Commit

Permalink
correctly push the zip file - fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 15, 2014
1 parent 256cdff commit c1af349
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';
var gulp = require('gulp');
var zip = require('./index');
var zip = require('./');

gulp.task('default', function () {
gulp.src('fixture/fixture.txt')
return gulp.src('fixture/fixture.txt')
.pipe(zip('test.zip'))
.pipe(gulp.dest('dest'));
});
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function (filename, opts) {
return;
}

cb(null, new gutil.File({
this.push(new gutil.File({
cwd: firstFile.cwd,
base: firstFile.base,
path: path.join(firstFile.base, filename),
Expand All @@ -56,5 +56,7 @@ module.exports = function (filename, opts) {
comment: opts.comment
})
}));

cb();
});
};
11 changes: 8 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ var zip = require('./');

it('should zip files', function (cb) {
var stream = zip('test.zip');
var i = 0;

stream.once('data', function (file) {
assert.equal(path.normalize(file.path), path.join(__dirname, './fixture/test.zip'));
stream.on('data', function (file) {
i++;
assert.equal(path.normalize(file.path), path.join(__dirname, 'fixture/test.zip'));
assert.equal(file.relative, 'test.zip');
assert(file.contents.length > 0);
});

stream.on('end', cb);
stream.on('end', function () {
assert(i === 1);
cb();
});

stream.write(new gutil.File({
cwd: __dirname,
Expand Down

0 comments on commit c1af349

Please sign in to comment.