sindresorhus / grunt-concurrent

Run grunt tasks concurrently

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grunt task with concurrent and watch

fxleblanc opened this issue · comments

I am trying to watch two directories concurrently and apply changes to each specific directory independently whenever that directory changes. The problem I encounter is when I launch the task, the console says it's watching but when I change a file, it doesn't trigger the watch tasks even if I specified the two watch tasks in the concurrent target.

module.exports = function(grunt){
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
  require('time-grunt')(grunt);

  grunt.initConfig({
    coffee:{
      models:{
        files:[{
      expand:true,
      cwd:'src/models/',
      src:['*.coffee'],
      dest:'dev/models/',
      ext:'.js'
    }]
      },
      tests:{
         files:[{
       expand:true,
       cwd:'src/tests/',
       src:['*.coffee'],
       dest:'dev/tests/',
       ext:'.js'
     }]
      }
    },
    coffeelint:{
      models:{
        files:{
      src:['src/models/*.coffee']
    }
      },
      tests:{
        files:{
      src:['src/tests/*.coffee']
    }
      }
    },
    watch:{
      models:{
        files:'src/models/*.coffee',
    tasks:['coffeelint:models', 'coffee:models']
      },
      tests:{
        files:'src/tests/*.coffee',
    tasks:['coffeelint:tests', 'coffee:tests']
      }
    },
    concurrent:{
      compile:['watch:models', 'watch:tests']
    }
  });

  grunt.registerTask('compile', ['concurrent:compile']);

};

No idea, but you don't need concurrent for this. The watch task will watch all targets for you.

grunt.registerTask('compile', ['watch']);

That's what I just found out (the hard way). Last ditch effort troubleshooting why watch wasn't working, I figured I'd try pointing my task directly to the watch, and it came back to life. 👍 I was just trying to be consistent setting everything in concurrent groups and went overboard. :/