I'm just getting started with Grunt and would like to run grunt-contrib-watch
[GitHub page] to lint my JavaScript every time a file is modified (with grunt-contrib-jshint
[GitHub page]) and run grunt-nodemon
[GitHub page] too, concurrently using grunt-concurrent
[GitHub page].
As I understand (which I evidently don't) my Gruntfile should:
- Run
concurrent
by default concurrent
runswatch
watch
runsjshint
every time a file is modified
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'
]);
};
N.B. I've not added grunt-nodemon
into the mix yet.
It looks like concurrent
is running watch
but when I modify a file it appears jshint
isn't running. I certainly don't get any output in the Terminal (I thought logConcurrentOutput: true
does this).
Here is the output I get in the Terminal:
Running "concurrent:dev" (concurrent) task
Running "watch" task
Waiting...
Done, without errors.
I would also like to run jshint
when I first run the default
task (as well as when I modify files).
Can anyone shed some light on where I am going wrong?
Thanks!