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

Strange behavior with event-stream.through() #47

Closed
hallister opened this issue Jun 13, 2014 · 1 comment
Closed

Strange behavior with event-stream.through() #47

hallister opened this issue Jun 13, 2014 · 1 comment

Comments

@hallister
Copy link

I've been spending the better part of a day trying to figure this out. For some reason, when using gulp-watch a pipe that calls event-stream.through() afterwards completely breaks. I'm attempting to get gulp-watch and gulp-inject to play nice together (gulp-inject issue at klei/gulp-inject#31).

gulp-inject adds a pipe to the stream that calls an event-stream.through(start, end) ( https://github.com/klei/gulp-inject/blob/master/index.js#L114). After start() successfully runs, end() is never called and the collector ends execution without end() ever getting called.

So the odd part, is this only happens when wrapping the stream with gulp-watch. If I remove gulp-watch and use a normal gulp.src everything works fine as seen below:

app = gulp.src(path.scripts)
  .pipe(watch(function(files) {
    return files
      .pipe(gulp.dest(path.build));
  }));

gulp.src('index.html')
  .pipe(debug())
  .pipe(inject(app))
  .pipe(debug())

This outputs:

[16:32:31] gulp-debug: (2014-06-13 23:32:31 UTC)

File
cwd:      C:\projects\app
base:     C:\projects\app\
path:     C:\projects\app\index.html
contents: <!DOCTYPE html>

<html lang="en">...

[16:32:31] gulp-debug: end event fired (2014-06-13 23:32:31 UTC)
[16:32:32] 6 files was added from pipe

The second debug() results in nothing since the inject wasn't able to complete. At this point, I'm not even sure if this is an event-stream bug or a gulp-watch bug.

@floatdrop
Copy link
Owner

Could you write what exactly you want to achieve by this task? As I see in mentioned issue in gulp-inject, you want to rebuild sass files on change and then rebuild index.html with injected css links? If so, then you should rewrite your gulp task to look like this: https://gist.github.com/floatdrop/44fb27635cd0e4fe5b43

You problem is that you passing stream from gulp-watch to gulp-inject, and gulp-inject expects 'end' event, which is never happens with gulp-watch stream.

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