Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synced tasks not waiting for complete finish before continuing #7

Open
Sawtaytoes opened this issue Oct 6, 2015 · 4 comments
Open

Comments

@Sawtaytoes
Copy link

If I do a delete, then a write, sometimes the write errors because the file being written is also being deleted at the same time.

Example:

gulp.task('html.rebuild', $.synchronize.sync([
    'html.clean',
    'html.build'
]));

In this example, clean removes the file and build will create the file. Clean is finishing up at the time build runs. It doesn't always happen, but it happens enough to be bothersome; especially when I run a bunch of async synced tasks at once.

@kaminaly
Copy link
Owner

kaminaly commented Oct 7, 2015

can i see your html.clean task code?

@Sawtaytoes
Copy link
Author

gulp.src(src)
  .pipe($.newer(dest))
  .pipe($.using({prefix: 'html.build', color: 'yellow'}))
  .pipe($.debug({title: 'html.build'}))
  .pipe(gulp.dest(dest))

@kaminaly
Copy link
Owner

kaminaly commented Oct 8, 2015

ok, maybe I've got it.
I use gulp sync feature for the gulp-sync.
so you have to fit in gulp's sync rule.

you can choose from 2 way below.

return Stream

gulp.task('html.clean', function(){
  return gulp.src(src)
    .pipe($.newer(dest))
    .pipe($.using({prefix: 'html.build', color: 'yellow'}))
    .pipe($.debug({title: 'html.build'}))
    .pipe(gulp.dest(dest));
});

do callback

gulp.task('html.clean', function(callback){
  gulp.src(src)
    .pipe($.newer(dest))
    .pipe($.using({prefix: 'html.build', color: 'yellow'}))
    .pipe($.debug({title: 'html.build'}))
    .pipe(gulp.dest(dest))
    .on('end', function(){
      callback();
    });
});

if you choose do callback, you have to care about error handling.
sometimes, it stops due to a gulp plugin error.
some plugins don't implement enough about error and end event.

@Sawtaytoes
Copy link
Author

Returning the stream didn't fix it, but I could try the callback method and see if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants