Code Monkey home page Code Monkey logo

Comments (5)

floatdrop avatar floatdrop commented on August 18, 2024

Hey. As readme says in top: Watch, that actually is an endless stream, so you should never get Task finished with endless watch routine, but you can use similar syntax as gulp.watch has - passing array of tasks to gulp-watch.

I'm not good at coffeescript, but here some code for you:

First - you can just pipe watch to a less:

gulp.task 'less-styles', () ->
  watch(glob: [
      'src/styles/*.less',
      'src/styles/font-awesome/font-awesome.less'
    ])
    .pipe less(
        paths: [pathModule.join(__dirname, 'less', 'includes')]
      )
    .on 'error', notify.onError
        message: 'Error: <%= error.message %>',
        title: 'Error in styles'
      .on 'finish', () ->
        console.log "FOO!"
      .pipe gulp.dest './ui/styles'
  )

Second - you can use gulp-debug to see, which file was recompiled by less (if by any reason less is not printing files) or changed:

gulp.task 'less-styles', () ->
  watch(glob: [
      'src/styles/*.less',
      'src/styles/font-awesome/font-awesome.less'
    ])
    .pipe less(
        paths: [pathModule.join(__dirname, 'less', 'includes')]
      )
    .on 'error', notify.onError
        message: 'Error: <%= error.message %>',
        title: 'Error in styles'
    .pipe(debug())
    .pipe gulp.dest './ui/styles'
  )

If you really need exactly Task finished message, then move out less to a gulp task:

gulp.task 'watch-less-styles', () ->
    watch(glob: [
      'src/styles/*.less',
      'src/styles/font-awesome/font-awesome.less'
    ], ['less-styles'])

gulp.task 'less-styles', () ->
  gulp.src 'src/styles/**/*.less'
    .pipe less(
        paths: [pathModule.join(__dirname, 'less', 'includes')]
      )
    .on 'error', notify.onError
        message: 'Error: <%= error.message %>',
        title: 'Error in styles'
    .pipe gulp.dest './ui/styles'
  )

from gulp-watch.

perlun avatar perlun commented on August 18, 2024

Thanks for your help! I ended up doing it like this:

gulp.task 'less-styles', () ->
  watch(glob: [
      'src/styles/*.less',
      'src/styles/font-awesome/font-awesome.less'
    ])
    .pipe print()
    .pipe less(
      paths: [pathModule.join(__dirname, 'less', 'includes')]
    ).on 'error', notify.onError
      message: 'Error: <%= error.message %>',
      title: 'Error in styles'
    .pipe gulp.dest './ui/styles'

...which works well for me. Again, thank you! 😄

from gulp-watch.

pleerock avatar pleerock commented on August 18, 2024

I cant use this plugin with run-sequence plugin because it never fires finish. Maybe you would add some options to turn off this endless stream? Because sometimes you want to run your tasks in a sequence but its hard with non controlled endless stream

from gulp-watch.

floatdrop avatar floatdrop commented on August 18, 2024

@pleerock how you imagine watch functionality to not be an 'endless'? Watch for some time?


In fact, you can. Because watch task should be without cb:

gulp.task('watch', function () { 
    watch(src, function () { });
})

In this case, gulp will not wait for this task to end.

from gulp-watch.

pleerock avatar pleerock commented on August 18, 2024

Do a watch as a secondary function. Use less to compile (do the task and finish it), and less-watch to watch and compile

from gulp-watch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.