sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

problem using gulp-clean #36

Closed luisrudge closed 9 years ago

luisrudge commented 9 years ago

Hi! I'm having a problem when I'm using gulp-clean. It's pretty hard to reproduce, but, basically, everytime I use gulp-clean or rimraf, the generated zip misses some files.

This works:

gulp.task('clean', function() {
  rimraf.sync(opts.build);
});

gulp.task('zip', ['build'], function() {
  return gulp.src([
      opts.build + '**/*.*'
    ], {
      base: opts.build
    })
    .pipe(using())
    .pipe(zip('build.zip'))
    .pipe(gulp.dest(opts.build));
});
gulp.task('build', ['config', 'webconfig', 'vendor', 'less', 'js', 'html', 'index']);

This doesn't:

gulp.task('clean', function() {
  rimraf.sync(opts.build);
});

gulp.task('zip', ['build'], function() {
  return gulp.src([
      opts.build + '**/*.*'
    ], {
      base: opts.build
    })
    .pipe(using())
    .pipe(zip('build.zip'))
    .pipe(gulp.dest(opts.build));
});
gulp.task('build', ['clean', 'config', 'webconfig', 'vendor', 'less', 'js', 'html', 'index']);

Notice the clean in the second 'build' task. Whenever I run the second example, the zip task misses two files (app.js and index.html). The first example runs just fine, but I can't guarantee that all files are the new files. Any thoughts?

sindresorhus commented 9 years ago

Tasks run concurrently, not serially. You need to run clean before zip, not at once.

luisrudge commented 9 years ago
gulp.task('zip', ['build'], function() {
});

zip will only run after build is complete. It's not running both tasks in parallel

viniciostorres commented 8 years ago

Is this problem resolved?