我刚刚开始使用 Grunt,并且想在每次修改文件(使用[GitHub page])时运行grunt-contrib-watch
[GitHub page]来检查我的 JavaScript ,并同时使用[GitHub page] 运行 [GitHub page ]。grunt-contrib-jshint
grunt-nodemon
grunt-concurrent
据我了解(我显然不了解)我的 Gruntfile 应该:
concurrent
默认运行concurrent
运行watch
watch
jshint
每次修改文件时运行
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
concurrent: {
dev: [
'watch'
],
options: {
logConcurrentOutput: true
}
},
jshint: {
server: [
'**/*.js',
'!node_modules/**/*.js'
],
options: {
node: true
}
},
watch: {
all: [
'**/*/.js',
'!node_modules/**/*.js'
],
tasks: [
'jshint'
]
}
});
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concurrent:dev'/*,
'jshint',
'watch'*/
]);
};
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concurrent:dev'
]);
};
注意我还没有添加grunt-nodemon
到组合中。
它看起来concurrent
正在运行watch
,但是当我修改文件时,它似乎jshint
没有运行。我当然没有在终端中得到任何输出(我认为logConcurrentOutput: true
这样做)。
这是我在终端中得到的输出:
Running "concurrent:dev" (concurrent) task
Running "watch" task
Waiting...
Done, without errors.
我也想jshint
在我第一次运行default
任务时运行(以及当我修改文件时)。
谁能阐明我哪里出错了?
谢谢!