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

gulp.trigger(taskName) should be a through stream #32

Closed
yocontra opened this issue Dec 1, 2013 · 6 comments
Closed

gulp.trigger(taskName) should be a through stream #32

yocontra opened this issue Dec 1, 2013 · 6 comments

Comments

@yocontra
Copy link
Member

yocontra commented Dec 1, 2013

This makes this use case possible

gulp = require 'gulp'

coffee = require 'gulp-coffee'
minify = require 'gulp-minify'

gulp.task 'reload', ->
  # do some live reload stuff here

gulp.task 'coffee', ->
  # compile, minify, and copy all coffee-script
  gulp.files("./client/js/**", {ignore:["vendor"]})
    .pipe(coffee)
    .pipe(minify)
    .pipe(gulp.folder("./public/js"))
    .pipe(gulp.trigger('reload'))

gulp.task 'js', ->
  # minify and copy all vendor files
  gulp.files("./client/js/vendor/**")
    .pipe(minify)
    .pipe(gulp.folder("./public/js/vendor"))
    .pipe(gulp.trigger('reload'))

gulp.task 'default', ->
  gulp.run 'js', 'coffee'

  gulp.watch "./client/js/**", ->
    gulp.run 'js', 'coffee'

So really just an es.map stream that does nothing but trigger a task and passes the same file through when its done.

@robrich
Copy link
Contributor

robrich commented Dec 2, 2013

If plugins could get a reference to the gulp engine, this would make a cool plugin.

@yocontra
Copy link
Member Author

yocontra commented Dec 4, 2013

@robrich that can be dangerous though. Plugins should be relatively stateless. If plugins were able to get into the task system I feel like that would lead to grunt where plugins are responsible for creating their own tasks in the system and you're supposed to just assume the names

@yocontra
Copy link
Member Author

yocontra commented Dec 4, 2013

The only question in my mind about this is the behavior. Should it fire for every file that passes through or should it wait until the entire upstream is done before firing then pass everything through? Flag to toggle each behavior?

@robrich
Copy link
Contributor

robrich commented Dec 4, 2013

I see the point. If plugins can reach into the main system, things could quickly get out of hand.

I think it should trigger on stream end as you can't pass the filename into the other task, and if you wanted to you should pipe into a plugin in the current task instead.

@yocontra
Copy link
Member Author

Closing this - I don't think it is a good idea (otherwise I would have implemented it by now)

If anyone has arguments for/against it I'm still open to discussion

@dashed
Copy link
Contributor

dashed commented Dec 27, 2013

An alternative is to execute the reload task within the run callback, since it is executed once all tasks are finished:

gulp.run 'js', 'coffee', (err)->
  gulp.run('reload') if !err

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

No branches or pull requests

3 participants