The watch
task exits if there are no files found to 'watch'; as per this issue.
To easily tell watch
to watch the same files as the jshint
task I used Grunt's templating engine to reference the same Array
of files as the jshint
task.
I then added jshint
to the list of concurrent tasks to run so it would be ran initially and as I modify files (with watch
).
Here is my working Gruntfile
:
module.exports = function (grunt) {
grunt.initConfig({
concurrent: {
dev: [
'jshint',
'watch'
],
options: {
logConcurrentOutput: true
}
},
jshint: {
server: [
'**/*.js',
'!node_modules/**/*.js'
],
options: {
node: true
}
},
watch: {
files: '<%= jshint.server %>',
tasks: [
'jshint'
]
}
});
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concurrent'
]);
};