运行shell命令和监视任务的单个Grunt任务?

时间:2013-12-11 21:41:08

标签: node.js gruntjs grunt-contrib-watch

鉴于此Gruntfile.coffee,我想保持shell:server任务正在运行并输出到shell,而watch检查前端资产的更改并向shell报告它运行我的:compile任务 全部来自同一个grunt命令到同一个shell。

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    coffee:
      compile:
        files:
          'public/js/app.js': 'assets/js/app.coffee'

    stylus:
      compile:
        files:
          'public/css/app.css': 'assets/css/app.styl'

    watch:
      css:
        files: 'assets/**/*.styl'
        tasks: 'stylus'
      javascript:
        files: 'assets/**/*.coffee'
        tasks: 'coffee'

    shell:
      server:
        command: 'supervisor index.coffee'
        options:
          stdout: true

  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-contrib-stylus')
  grunt.loadNpmTasks('grunt-contrib-watch')
  grunt.loadNpmTasks('grunt-shell')

  grunt.registerTask('work', ['default', 'shell:server', 'watch'])
  grunt.registerTask('default', ['coffee', 'stylus'])

奖励将取消supervisor,以支持使用Grunt监视服务器更改并重新启动Web服务器。

1 个答案:

答案 0 :(得分:0)

选项:

  1. 查看其中一个任务是否提供background: true选项(grunt-karma确实如此,例如IIRC)

  2. 查看grunt-parallel