2013-10-02 47 views
0

你好,我正试图设置一个观察者,但我得到的只是这个在控制台中。观察者在Grunt中不工作

$咕噜watchTest

运行 “监视” 任务

等待... $

所以没有实际的等待。我尝试了茉莉花任务,并按预期工作。我有我错过了什么?

module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 
    uglify: { 
     options: { 
     banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' 
     }, 
     build: { 
     src: 'src/main.js', 
     dest: 'build/<%= pkg.name %>.min.js' 
     } 
    }, 

    jasmine : { 
     src : 'src/**/*.js', 
     options : { 
     specs : 'src/test/specs/**/*.js' 
     } 
    }, 

    watch: { 
     src : 'src/**/*.js', 
     tasks: ['jasmine'] 
    } 

    }); 


    // Load the plugin that provides the "uglify" task. 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-contrib-jasmine'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 

    // Default task(s). 
    grunt.registerTask('default', ['uglify']); 
    grunt.registerTask('test', ['jasmine']); 
    grunt.registerTask('watchTest', ['watch']); 

}; 

回答

1

您的手表配置不正确;用这个替换它:

watch: { 
    jasmine: { 
     files: ['src/**/*.js'], 
     tasks: ['jasmine'] 
    } 
} 

另外,你不需要注册一个任务别名只是看自己;运行grunt watch将达到相同的结果。希望这可以帮助。

+0

它的工作原理。谢谢! – pethel

+0

不客气! :-) – Ben